using System;
using System.Collections.Generic;
using System.ServiceModel;

using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.DataContracts.Reports;

namespace BeWo.Service.ServiceContracts
{
    [ServiceContract]
    public interface IOperationsService
    {
        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateInvoices(List<InvoiceDC> invoices);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateServiceCategories(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateServiceCategory(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateServiceDescription(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateServiceDescriptions(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteAccountingTransaction(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteAccountingTransactions(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteFileAttachment(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteFileAttachments(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceCategories(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceCategory(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceDescription(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceDescriptions(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceRecord(long pOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteServiceRecords(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<Settlement2DC> GenerateInitialSettlementDCsForPeriod(long pCostBearer, DateTime periodStart, DateTime periodEnd);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        Settlement2DC GenerateInitialSettlementDC(long pCostBearer2SupportConceptOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        Settlement2DC GenerateInitialSettlementDCForPeriod(long pCostBearer2SupportConceptOid, DateTime? periodStart, DateTime? periodEnd);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<AccountingTransactionDC> GetAccountingTransactions(DateTimeSpan pSpan, long? pSupportConceptOid, long? pSupportConceptCostBearerRelOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<InvoiceDC> GetAllActiveInvoices();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<CompactSupportConceptDC> GetAllActiveSupportConceptCostbearer(bool onlyApproved, bool onlyWithAssignedCostbearer, long employeeOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<ServiceCategoryDC> GetAllServiceCategories();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<ServiceDescriptionDC> GetAllServiceDescriptions();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        string GetCompressedICD10Diagnosis();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        CustomerInfoDC GetCustomerInfosForCustomerOid(long customerOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<ServiceRecordDC> GetCustomerServiceRecords(long pCustomerOid, bool fetchArchivedSupportConcepts);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<ServiceRecordDC> GetCustomerServiceRecordsCompact(long pCustomerOid, long costbearer2SupportConceptOid, long? days);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<ServiceRecordDC> GetCustomerServiceRecordsInMonth(long pCustomerOid, DateTime pMonth);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<ServiceRecordDC> GetEmployeesServiceRecords(long pEmployeeOid);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
		List<ServiceRecordDC> GetEmployeesServiceRecords2(long pEmployeeOid, long? days);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<FileAttachmentDC> GetFileAttachments(TableID pObjectTid, long pObjectOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<BeWoFolderDC> GetFolderTree(TableID pObjectTid, long pObjectOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteFolder(long pBeWoFolderOid, long pVersion);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        long InsertNewFolder(BeWoFolderDC folder);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        BeWoFolderDC UpdateFolder(BeWoFolderDC folder);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        FileAttachmentDC UpdateFileAttachment(FileAttachmentDC file);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        MandatorDC GetMandator();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        ServiceRecordGroupDC GetServiceRecordGroup(long pGroupOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConcetInfoDC> GetSupportConceptInfosForSupportConceptOid(long supportConceptOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllActive();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllActiveWithCostbearer();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllCurrent();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConceptTreeNodeDC> GetSupportConceptTreeByEmployee(long pEmployeeOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<SupportConceptTreeNodeDC> GetSupportConceptTreeInSpan(DateTimeSpan pSpan);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        SupportConceptTreeNodeDetailInfoDC GetSupportConceptTreeNodeDetailInfo(long pCustomerOid, long? pSupportConceptOid, long? pCostbearer2SupportConceptOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        CompactOrganisationDC FillCostbearerDetails(CompactOrganisationDC dc);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<AccountingTransactionDC> GetUnassignedAccountingTransactions();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<VarFieldDC> GetVarFieldDefs(TableID tid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewAccountingTransactions(List<AccountingTransactionDC> pAccountingTransactions);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void InsertNewInvoices(List<InvoiceDC> invoices);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewServiceCategories(List<ServiceCategoryDC> pServiceCategories);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewServiceDescriptions(List<ServiceDescriptionDC> pServiceDescriptions);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        ServiceRecordGroupDC InsertNewServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewServiceRecords(List<ServiceRecordDC> pServiceRecords);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        long InsertNewServiceRecordAndSignature(ServiceRecordDC sr, SignatureDC sig);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        bool IsAlive();

        /// <summary>
        /// Returns an id string that has to be used as 
        /// the dcid parameter of the Report.aspx page
        /// </summary>
        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        string PrepareFLSReport(FLSAnalysisDataReportDC pReportDC, string id);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        string PrepareAuslastungReport(AuslastungAnalysisRootDC pReport, string id);

        /// <summary>
        /// Returns an id string that has to be used as 
        /// the dcid parameter of the Report.aspx page
        /// </summary>
        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        string PrepareSettlementReport(Settlement2DC pSettlementDC);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateAccountingTransactions(List<AccountingTransactionDC> pAccountingTransactions);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateInvoices(List<InvoiceDC> invoices);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        MandatorDC UpdateMandator(MandatorDC mandator);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateServiceCategories(List<ServiceCategoryDC> pServiceCategories);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateServiceDescriptions(List<ServiceDescriptionDC> pServiceDescriptions);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        ServiceRecordGroupDC UpdateServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateServiceRecords(List<ServiceRecordDC> pServiceRecords);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        SupportConceptStatisticsDC CreateSupportConceptStatistics(long costBearer2SupportConceptOid, DateTime statisticsDate);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<ServiceRecordHistoryDC> GetServiceRecordHistory(long serviceRecordOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void ResetTenant(String tenant);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void ResetAllTenants();

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        bool DoesNotOverlapWithOtherServiceRecord(ServiceRecordDC pServiceRecord, long customerOid, long? employeeOid);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<AdditionalServiceDC> GetAllAdditionalService();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<AdditionalServiceRegionDC> GetAllAdditionalServiceRegion();

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<AdditionalServiceGroupOfPeopleRelationDC> GetAllAdditionalServiceGroupOfPeopleRelation();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<AdditionalServiceGroupOfPeopleDC> GetAllAdditionalServiceGroupOfPeople();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewAdditionalServiceGroupOfPeopleRelations(
            List<AdditionalServiceGroupOfPeopleRelationDC> pAdditionalServiceGroupOfPeopleRelations);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateAdditionalServiceGroupOfPeopleRelations(
            List<AdditionalServiceGroupOfPeopleRelationDC> pAdditionalServiceGroupOfPeopleRelations);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        void DeleteAdditionalServiceGroupOfPeopleRelation(long pDeleteAdditionalServiceGroupOfPeopleRelationOid, long pVersion);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        AdditionalServiceGroupOfPeopleDC UpdateAdditionalServiceGroupOfPeople(AdditionalServiceGroupOfPeopleDC pAdditionalServiceGroupOfPeople);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<long> InsertNewAdditionalServiceGroupsOfPeople(List<AdditionalServiceGroupOfPeopleDC> pGroups);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
		List<AdditionalServiceBookingDC> GetAllAdditionalServiceBookings(long? regionOid, DateTime start, DateTime end);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<long> InsertNewAdditionalServiceBookings(List<AdditionalServiceBookingDC> pAdditionalServiceBookings);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        void UpdateAdditionalServiceBookings(List<AdditionalServiceBookingDC> pAdditionalServiceBookings);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteAdditionalServiceBookings(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        long InsertNewAdditionalServiceRegion(AdditionalServiceRegionDC pAdditionalServiceRegionDC);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        AdditionalServiceRegionDC GetAdditionalServiceRegion(long pRegionOid);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    List<ServiceRecordValidationResultDC> ValidateServiceRecordEntry(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, bool isGroupRecord, IList<long> employeeOids);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord,
		    SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed,
		    IList<long> employeeOids, IList<long> cb2scOids);
		
	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    List<long> InsertNewAdditionalServices(IEnumerable<AdditionalServiceDC> pAdditionalServiceDcs);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    void UpdateAdditionalServices(List<AdditionalServiceDC> pAdditionalServices);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    List<long> InsertNewAdditionalServiceRegions(List<AdditionalServiceRegionDC> pAdditionalServiceRegions);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    void DeactivateAdditionalServiceRegions(Dictionary<long, long> pOid2Version);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    void UpdateAdditionalServiceRegions(List<AdditionalServiceRegionDC> pAdditionalServiceRegions);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    void DeactivateAdditionalServices(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        bool OverlapsWithAnotherAdditionalServiceBooking(long additionalServiceRegionOid, List<long> customerOids, DateTime pDatum);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        bool AssessmentSheetEntryBelongsToAddServices(long assessmentSheetCategoryOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<AdditionalServiceBookingDC> GetAllAdditionalServiceBookingsForCustomer(long customerOid, DateTime start, DateTime end);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        List<ServiceRecordValidationResult> CheckExistingSettlementInvoices(ServiceRecordDC pServiceRecord);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        Dictionary<ServiceRecordDC, List<ServiceRecordValidationResult>> ValidateGroupServiceRecordEntry(ServiceRecordDC pServiceRecord, List<ServiceRecordDC> groupServiceRecords, List<CompactEmployeeDC> employees, DateTime? date, int maxDaysEditServiceRecordsAllowed, decimal flsTotalRounded, out Dictionary<long, string> overlappingRecords, out Dictionary<long, string> overlappingEmployees);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        ServiceRecordDC GetServiceRecordById(long pId);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        FileAttachmentDC DoTheRealFileUpdate(FileAttachmentDC file);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<FileAttachmentDC> GetFileAttachmentInfoByType(FileAttachmentType fileAttachmentType);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    String GetLicenseOrderUrl();

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    LicenseInfoDC GetLicenseInfo();

		[FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    GroupDurationDC CalculateGroupDuration(int personCount, int employeeCount, decimal totalDuration);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
		GroupDurationDC CalculateGroupDuration2(int personCount, int employeeCount, decimal totalDuration, long[] costBearer2SupportConceptArray);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    List<ServiceDescriptionDC> FindServiceDescriptionsForCategory(long pCategoryOid);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    ServiceDescriptionDC GetServiceDescription(long pServiceDescriptionOid);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    List<ServiceRecordDC> GetActiveServiceRecordsBySupportConcept(long pSupportConceptOid);

	    [FaultContract(typeof (BeWoFault))]
	    [OperationContract]
	    void InsertBeWoMobilBrowserInfo(BeWoMobilBrowserInfoDC browserInfo);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
		IList<UiElementDC> GetUiElements(UiElementType? uiType, long? employeeOid, long? teamOid, long[] oidArray);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
		IList<ServiceRecordDC> FindServiceRecordsForLastDays(long? costbearer2SupportConceptOid, int days, long? employeeOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        IList<TextbausteinDC> GetAllTextbausteine();

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        IList<long> InsertNewTextbausteine(IEnumerable<TextbausteinDC> pTextbausteine);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void UpdateTextbausteine(List<TextbausteinDC> pTextbausteine);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeleteTextbausteine(Dictionary<long, long> pOid2Version);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        IList<TextbausteinDC> GetTextbausteineByServiceCategory(long pServiceCategoryOid);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    IList<ServiceRecordDC> FindServiceRecordsInSpan(long pCostBearer2SupportConceptOid, DateTimeSpan period);

		[FaultContract(typeof(BeWoFault))]
		[OperationContract]
	    List<ServiceRecordDC> GetEmployeesServiceRecordsInSpan(long pEmployeeOid, DateTimeSpan limitinDateTimeSpan);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        SignatureDC InsertSignature(SignatureDC sig);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        ChatMessageDC CreateNewChatMessagesDC(long senderOid, long empfängerOid, string message);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        CustomerAPPCodeDC CreateNewIsChatActiveCustomerAPPCodeDC(long customerOid, int activeType);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        EmployeeAPPCodeDC CreateNewIsChatActiveEmployeeAPPCodeDC(long employeeOid, int activeType);

        [FaultContract(typeof (BeWoFault))]
        [OperationContract]
        EmployeeAPPCodeDC CreateNewNotfallNacrichtEmployeeAPPCodeDC(long employeeOid, String notfallstate);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<OrganisationPersonRelationDC> LoadOrganisationPersonRelationsByOid(IEnumerable<long> pOids);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        List<BargeldkassenDC> LoadBargeldkassenForObject(TableID objectTid, long objectOid);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        long InsertNewBargeldkasse(BargeldkassenDC pBargeldkasse);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        BargeldkassenDC UpdateBargeldkasse(BargeldkassenDC pBargeldkasse);

        [FaultContract(typeof(BeWoFault))]
        [OperationContract]
        void DeactivateBargeldkasse(long pOid, long pVersion);
    }
}