@@ -2497,4 +2497,375 @@ public void SetState(DStateInfo stateInfo)
2497
2497
SetState ( stateInfo . State , stateInfo . PersonId , stateInfo . PositionId , stateInfo . Date ) ;
2498
2498
}
2499
2499
}
2500
+
2501
+ [ ProtoContract ( EnumPassthru = true ) ]
2502
+ public enum FileArchiveCheckOperationState
2503
+ {
2504
+ NotStarted ,
2505
+ Running ,
2506
+ Completed ,
2507
+ CompletedWithError
2508
+ }
2509
+
2510
+ [ ProtoContract ]
2511
+ public class DFileArchiveCheckState
2512
+ {
2513
+ [ ProtoMember ( 1 ) ]
2514
+ public DateTime StartTime { get ; set ; }
2515
+ [ ProtoMember ( 2 ) ]
2516
+ public FileArchiveCheckOperationState State { get ; set ; }
2517
+ [ ProtoMember ( 3 ) ]
2518
+ public long CheckedCount { get ; set ; }
2519
+ [ ProtoMember ( 4 ) ]
2520
+ public long TotalCount { get ; set ; }
2521
+ [ ProtoMember ( 5 ) ]
2522
+ public string Error { get ; set ; }
2523
+ [ ProtoMember ( 6 ) ]
2524
+ public bool HasErrors { get ; set ; }
2525
+ }
2526
+
2527
+ [ ProtoContract ]
2528
+ public class DPersonUpdateInfo
2529
+ {
2530
+ [ ProtoMember ( 1 ) ]
2531
+ public Guid Id { get ; set ; }
2532
+
2533
+ [ ProtoMember ( 2 ) ]
2534
+ public bool ? IsInactive { get ; set ; }
2535
+
2536
+ [ ProtoMember ( 3 ) ]
2537
+ public string Comment { get ; set ; }
2538
+
2539
+ [ ProtoMember ( 4 ) ]
2540
+ public string Email { get ; set ; }
2541
+
2542
+ public DPersonUpdateInfo ( )
2543
+ {
2544
+ IsInactive = null ;
2545
+ Comment = null ;
2546
+ Email = null ;
2547
+ }
2548
+ }
2549
+
2550
+ [ ProtoContract ]
2551
+ public class DOrganisationUnitUpdateInfo
2552
+ {
2553
+ public DOrganisationUnitUpdateInfo ( )
2554
+ {
2555
+ VicePersons = new List < int > ( ) ;
2556
+ }
2557
+
2558
+ [ ProtoMember ( 1 ) ]
2559
+ public List < int > VicePersons { get ; }
2560
+ }
2561
+
2562
+ [ ProtoContract ]
2563
+ public class DChatChange
2564
+ {
2565
+ [ ProtoMember ( 1 ) ]
2566
+ public DChat Chat { get ; set ; }
2567
+ [ ProtoMember ( 2 ) ]
2568
+ public bool IsRenamed { get ; set ; }
2569
+ [ ProtoMember ( 3 ) ]
2570
+ public bool IsDescriptionChanged { get ; set ; }
2571
+ }
2572
+
2573
+ [ ProtoContract ]
2574
+ public class DChat
2575
+ {
2576
+ [ ProtoMember ( 1 ) ]
2577
+ public Guid Id { get ; set ; }
2578
+ [ ProtoMember ( 2 ) ]
2579
+ public string Name { get ; set ; }
2580
+
2581
+ [ ProtoMember ( 3 ) ]
2582
+ public int CreatorId { get ; set ; }
2583
+ [ ProtoMember ( 4 ) ]
2584
+ public ChatKind Type { get ; set ; }
2585
+ [ ProtoMember ( 5 ) ]
2586
+ public Guid ? LastMessageId { get ; set ; }
2587
+ [ ProtoMember ( 6 ) ]
2588
+ public DateTime CreationDateUtc { get ; set ; }
2589
+ [ ProtoMember ( 7 ) ]
2590
+ public string Description { get ; set ; }
2591
+
2592
+ public DChat Clone ( )
2593
+ {
2594
+ return new DChat
2595
+ {
2596
+ Id = Id ,
2597
+ CreatorId = CreatorId ,
2598
+ Name = Name ,
2599
+ Description = Description ,
2600
+ Type = Type ,
2601
+ LastMessageId = LastMessageId ,
2602
+ CreationDateUtc = CreationDateUtc
2603
+ } ;
2604
+ }
2605
+ }
2606
+
2607
+ [ ProtoContract ( EnumPassthru = true ) ]
2608
+ public enum ChatKind
2609
+ {
2610
+ Personal = 0 ,
2611
+ Group = 1
2612
+ }
2613
+
2614
+ [ ProtoContract ]
2615
+ public class DChatInfo
2616
+ {
2617
+ [ ProtoMember ( 1 ) ]
2618
+ public DChat Chat { get ; set ; }
2619
+ [ ProtoMember ( 2 ) ]
2620
+ public DMessage LastMessage { get ; set ; }
2621
+ [ ProtoMember ( 3 ) ]
2622
+ public int UnreadMessagesNumber { get ; set ; }
2623
+ [ ProtoMember ( 4 ) ]
2624
+ public List < DChatRelation > Relations { get ; set ; }
2625
+
2626
+ public DChatInfo ( )
2627
+ {
2628
+ Chat = new DChat ( ) ;
2629
+ LastMessage = new DMessage ( ) ;
2630
+ Relations = new List < DChatRelation > ( ) ;
2631
+ }
2632
+ }
2633
+
2634
+ [ ProtoContract ]
2635
+ public class DChatMember
2636
+ {
2637
+ [ ProtoMember ( 1 ) ]
2638
+ public Guid ChatId { get ; set ; }
2639
+ [ ProtoMember ( 2 ) ]
2640
+ public int PersonId { get ; set ; }
2641
+ [ ProtoMember ( 3 ) ]
2642
+ public bool IsAdmin { get ; set ; }
2643
+ [ ProtoMember ( 4 ) ]
2644
+ public bool IsDeleted { get ; set ; }
2645
+ [ ProtoMember ( 5 ) ]
2646
+ public bool IsNotifiable { get ; set ; }
2647
+ [ ProtoMember ( 6 ) ]
2648
+ public DateTime DateUpdatedUtc { get ; set ; }
2649
+ }
2650
+
2651
+ [ ProtoContract ]
2652
+ public class DTextMessageData
2653
+ {
2654
+ public DTextMessageData ( )
2655
+ {
2656
+ Attachments = new List < DChatRelation > ( ) ;
2657
+ }
2658
+
2659
+ [ ProtoMember ( 1 ) ]
2660
+ public string Text { get ; set ; }
2661
+ [ ProtoMember ( 2 ) ]
2662
+ public List < DChatRelation > Attachments { get ; set ; }
2663
+ }
2664
+
2665
+ [ ProtoContract ]
2666
+ public class DMemberChange
2667
+ {
2668
+ [ ProtoMember ( 1 ) ]
2669
+ public int PersonId { get ; set ; }
2670
+ [ ProtoMember ( 2 ) ]
2671
+ public bool ? IsAdded { get ; set ; }
2672
+ [ ProtoMember ( 3 ) ]
2673
+ public bool ? IsDeleted { get ; set ; }
2674
+ [ ProtoMember ( 4 ) ]
2675
+ public bool ? IsAdmin { get ; set ; }
2676
+ [ ProtoMember ( 5 ) ]
2677
+ public bool ? IsNotifiable { get ; set ; }
2678
+ }
2679
+
2680
+ [ ProtoContract ]
2681
+ public class DChatMembersData
2682
+ {
2683
+ [ ProtoMember ( 1 ) ]
2684
+ public List < DMemberChange > Changes { get ; }
2685
+ [ ProtoMember ( 2 ) ]
2686
+ public string Title { get ; set ; }
2687
+
2688
+ public DChatMembersData ( )
2689
+ {
2690
+ Changes = new List < DMemberChange > ( ) ;
2691
+ }
2692
+ }
2693
+
2694
+ [ ProtoContract ]
2695
+ public class NotifiableDMessage
2696
+ {
2697
+ [ ProtoMember ( 1 ) ]
2698
+ public DMessage Message { get ; set ; }
2699
+ [ ProtoMember ( 2 ) ]
2700
+ public bool IsNotifiable { get ; set ; }
2701
+ }
2702
+
2703
+ [ ProtoContract ]
2704
+ public class DMessage
2705
+ {
2706
+ [ ProtoMember ( 1 ) ]
2707
+ public Guid Id { get ; set ; }
2708
+ [ ProtoMember ( 2 ) ]
2709
+ public byte [ ] Data { get ; set ; }
2710
+ [ ProtoMember ( 3 ) ]
2711
+ public int CreatorId { get ; set ; }
2712
+ [ ProtoMember ( 4 ) ]
2713
+ public DateTime ? ServerDate { get ; set ; }
2714
+ [ ProtoMember ( 5 ) ]
2715
+ public DateTime LocalDate { get ; set ; }
2716
+ [ ProtoMember ( 6 ) ]
2717
+ public Guid ChatId { get ; set ; }
2718
+ [ ProtoMember ( 7 ) ]
2719
+ public Guid ? RelatedMessageId { get ; set ; }
2720
+ [ ProtoMember ( 8 ) ]
2721
+ public MessageType Type { get ; set ; }
2722
+ [ ProtoMember ( 9 ) ]
2723
+ public List < DMessage > RelatedMessages { get ; set ; }
2724
+
2725
+ public DMessage ( )
2726
+ {
2727
+ RelatedMessages = new List < DMessage > ( ) ;
2728
+ }
2729
+
2730
+ public override bool Equals ( object obj )
2731
+ {
2732
+ if ( ReferenceEquals ( null , obj ) ) return false ;
2733
+ if ( ReferenceEquals ( this , obj ) ) return true ;
2734
+ if ( obj . GetType ( ) != GetType ( ) ) return false ;
2735
+ return Equals ( ( DMessage ) obj ) ;
2736
+ }
2737
+
2738
+ public override int GetHashCode ( )
2739
+ {
2740
+ unchecked
2741
+ {
2742
+ var hashCode = Id . GetHashCode ( ) ;
2743
+ hashCode = ( hashCode * 397 ) ^ ( Data != null ? Data . GetHashCode ( ) : 0 ) ;
2744
+ hashCode = ( hashCode * 397 ) ^ CreatorId ;
2745
+ hashCode = ( hashCode * 397 ) ^ ServerDate . GetHashCode ( ) ;
2746
+ hashCode = ( hashCode * 397 ) ^ LocalDate . GetHashCode ( ) ;
2747
+ hashCode = ( hashCode * 397 ) ^ ChatId . GetHashCode ( ) ;
2748
+ hashCode = ( hashCode * 397 ) ^ RelatedMessageId . GetHashCode ( ) ;
2749
+ hashCode = ( hashCode * 397 ) ^ ( int ) Type ;
2750
+ hashCode = ( hashCode * 397 ) ^ ( RelatedMessages != null ? RelatedMessages . GetHashCode ( ) : 0 ) ;
2751
+ return hashCode ;
2752
+ }
2753
+ }
2754
+
2755
+ public bool Equals ( DMessage dMessage )
2756
+ {
2757
+ return Id == dMessage . Id && Data . SequenceEqual ( dMessage . Data ) && CreatorId == dMessage . CreatorId &&
2758
+ ServerDate == dMessage . ServerDate && LocalDate == dMessage . LocalDate &&
2759
+ RelatedMessageId == dMessage . RelatedMessageId && ChatId == dMessage . ChatId && Type == dMessage . Type ;
2760
+ }
2761
+ }
2762
+
2763
+ [ ProtoContract ]
2764
+ public class DChatRelation
2765
+ {
2766
+ [ ProtoMember ( 1 ) ]
2767
+ public Guid ObjectId { get ; set ; }
2768
+ [ ProtoMember ( 2 ) ]
2769
+ public ChatRelationType Type { get ; set ; }
2770
+ [ ProtoMember ( 3 ) ]
2771
+ public Guid ? MessageId { get ; set ; }
2772
+ [ ProtoMember ( 4 ) ]
2773
+ public bool IsDeleted { get ; set ; }
2774
+ }
2775
+
2776
+ public enum ChatRelationType
2777
+ {
2778
+ Relation = 0 ,
2779
+ Attach = 1
2780
+ }
2781
+
2782
+ public class DMessagePerson
2783
+ {
2784
+ public Guid MessageId { get ; set ; }
2785
+ public int PersonId { get ; set ; }
2786
+ public bool IsSent { get ; set ; }
2787
+ public bool IsRead { get ; set ; }
2788
+ }
2789
+
2790
+ public enum MessageType
2791
+ {
2792
+ TextMessage = 0 ,
2793
+ ChatCreation = 1 ,
2794
+ ChatMembers = 2 ,
2795
+ MessageRead = 3 ,
2796
+ MessageAnswer = 4 ,
2797
+ ChatChanged = 5 ,
2798
+ ChatRelation = 6
2799
+ }
2800
+
2801
+ public static class DataClassesExtensions
2802
+ {
2803
+ public static void Add ( this List < DChild > children , DObject child )
2804
+ {
2805
+ children . Add ( new DChild { ObjectId = child . Id , TypeId = child . TypeId } ) ;
2806
+ }
2807
+
2808
+ public static void Add ( this List < DChild > children , Guid childId , int typeId )
2809
+ {
2810
+ children . Add ( new DChild { ObjectId = childId , TypeId = typeId } ) ;
2811
+ }
2812
+
2813
+ public static void AddRange ( this List < DChild > children , params DObject [ ] toAdd )
2814
+ {
2815
+ children . AddRange ( toAdd . Select ( x => new DChild { TypeId = x . TypeId , ObjectId = x . Id } ) ) ;
2816
+ }
2817
+
2818
+ public static void Remove ( this List < DChild > children , Guid objectId )
2819
+ {
2820
+ children . RemoveAll ( x => x . ObjectId == objectId ) ;
2821
+ }
2822
+
2823
+ public static bool Contains ( this IEnumerable < DChild > children , Guid objectId )
2824
+ {
2825
+ return children . Any ( x => x . ObjectId == objectId ) ;
2826
+ }
2827
+
2828
+ public static IEnumerable < Guid > OfType ( this IEnumerable < DChild > children , int typeId )
2829
+ {
2830
+ return children . Where ( x => x . TypeId == typeId ) . Select ( x => x . ObjectId ) ;
2831
+ }
2832
+
2833
+ public static void AddDistinct ( this List < AccessRecord > access , IEnumerable < AccessRecord > toAdd )
2834
+ {
2835
+ access . AddRange ( toAdd . FastExcept ( access ) ) ;
2836
+ }
2837
+
2838
+ public static void AddDistinct ( this List < AccessRecord > access , AccessRecord record )
2839
+ {
2840
+ if ( ! access . Contains ( record ) )
2841
+ access . Add ( record ) ;
2842
+ }
2843
+
2844
+ public static void RemoveAll ( this List < AccessRecord > access , IEnumerable < AccessRecord > toRemove )
2845
+ {
2846
+ foreach ( var record in toRemove )
2847
+ {
2848
+ access . Remove ( record ) ;
2849
+ }
2850
+ }
2851
+ }
2852
+
2853
+ public static class ByteExtensions
2854
+ {
2855
+ public static bool IsBitSet ( this byte b , int pos )
2856
+ {
2857
+ if ( pos < 0 || pos > 7 )
2858
+ throw new ArgumentOutOfRangeException ( "pos" , "Index must be in the range of 0-7." ) ;
2859
+
2860
+ return ( b & ( 1 << pos ) ) != 0 ;
2861
+ }
2862
+
2863
+ public static byte SetBit ( this byte b , int pos , bool value )
2864
+ {
2865
+ if ( pos < 0 || pos > 7 )
2866
+ throw new ArgumentOutOfRangeException ( "pos" , "Index must be in the range of 0-7." ) ;
2867
+
2868
+ return value ? ( byte ) ( b | ( 1 << pos ) ) : ( byte ) ( b & ~ ( 1 << pos ) ) ;
2869
+ }
2870
+ }
2500
2871
}
0 commit comments