Пример #1
0
 public AddNewEmail()
 {
     mlb = new methodLibrary();
     APILibrary = new Library_APICall();
     mselectrecipient = new ObservableCollection<CollectionUsersTeamMembers>();
     ruser = new RootObjectUsers();
     teamid_temp = 0;
     memberid = 0;
     parameterPresent = false;
     recipient_ids = null;
     recipient_names = null;
     rcem = new CollectionEventAvailabilityMembers();
     this.Loaded += AddNewEmail_Loaded;
     this.InitializeComponent();
 }
Пример #2
0
        public static async Task<bool> updateAvailability(RootObjectUsers rusers)
        {
            methodLibrary mlib = new methodLibrary();
            Dictionary<long, int> rteams_ht = new Dictionary<long, int>();
            if (rusers.teams != null)
            {
                for (int i = 0; i < rusers.teams.Count; i++)
                {
                    if (!rteams_ht.ContainsKey(rusers.teams[i].id))
                    {
                        rteams_ht.Add(rusers.teams[i].id, i);
                    }
                }
            }
            RootObjectEventAvailability reventavailability = new RootObjectEventAvailability();
            for (int teami = 0; teami < rusers.teams.Count; teami++)
            {
                try
                {
                    string response = await mlib.readFile("teamAvailabilityAPI" + rusers.teams[teami].id);
                    long manager_memberid = 0;
                    long owner_memberid = 0;
                    RootObjectAvailabilityAPI ravailbilityAPI = AvailabilityAPI.availabilityAPIDataDeserializer(response);
                    RootObjectEventAvailability reventavail = new RootObjectEventAvailability();
                    reventavail.eventMemberAvailability = new ObservableCollection<CollectionEventAvailabilityMembers>();
                    if (ravailbilityAPI.collection.items != null)  //meaning there is some availability defined in there
                    {
                        Dictionary<string, int> ravailibityAPI_items_ht = new Dictionary<string, int>();
                        for (int i = 0; i < ravailbilityAPI.collection.items[0].data.Count; i++)
                        {
                            if (!ravailibityAPI_items_ht.ContainsKey(ravailbilityAPI.collection.items[0].data[i].name))
                            {
                                ravailibityAPI_items_ht.Add(ravailbilityAPI.collection.items[0].data[i].name, i);
                            }
                            
                        }
                        Dictionary<object, int> ravailabilityAPI_events_ht = new Dictionary<object, int>();
                        int pos = 0;
                        for (int i = 0; i < ravailbilityAPI.collection.items.Count; i++)
                        {
                            if (!ravailabilityAPI_events_ht.ContainsKey(ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value))
                            {
                                if(!ravailabilityAPI_events_ht.ContainsKey(ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value))
                                {
                                    ravailabilityAPI_events_ht.Add(ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value, pos);
                                }
                                CollectionEventAvailabilityMembers reventavailmembers = new CollectionEventAvailabilityMembers();
                                //reventavailmembers.hrefForThisEvent = ravailbilityAPI.collection.items[i].href;
                                reventavailmembers.eventid = ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value == null ? 0 : (long)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value;
                                reventavailmembers.team_id = ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["team_id"]].value == null ? 0 : (long)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["team_id"]].value;
                                reventavailmembers.manager_memberID = rusers.teams[(int)rteams_ht[reventavailmembers.team_id]].teamManagerMemberId;
                                manager_memberid = reventavailmembers.manager_memberID;
                                reventavailmembers.owner_memberID = rusers.teams[(int)rteams_ht[reventavailmembers.team_id]].teamOwnerMemberId;
                                owner_memberid = reventavailmembers.owner_memberID;
                                reventavailmembers.currentUser_memberID = rusers.teams[(int)rteams_ht[reventavailmembers.team_id]].loggedInUsersmemberID;
                                reventavail.eventMemberAvailability.Add(reventavailmembers);
                                pos++;
                            }
                            MemberAvailabilityStatus rmemstatus = new MemberAvailabilityStatus();
                            try
                            {
                                rmemstatus.updateMemberAvailabilityhref = ravailbilityAPI.collection.items[i].href;
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine("Exception in storing the availability API of a member : " + ex);
                                await mlb.writeToLogFile("xception in storing the availability API of a member : " + ex, false);
                            }
                            rmemstatus.member_id = ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["member_id"]].value == null ? 0 : (long)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["member_id"]].value;
                            rmemstatus.notes = (string)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["notes"]].value;
                            rmemstatus.notes_author_member_id = ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["notes_author_member_id"]].value == null ? -1 : (long)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["notes_author_member_id"]].value;
                            rmemstatus.status_code = ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["status_code"]].value == null ? -1 : (long)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["status_code"]].value;
                            rmemstatus.status_string = (string)ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["status"]].value;
                            if (rmemstatus.member_id == manager_memberid)
                            {
                                rmemstatus.is_teammamager = true;
                            }
                            else
                            {
                                rmemstatus.is_teammamager = false;
                            }

                            if (rmemstatus.member_id == owner_memberid)
                            {
                                rmemstatus.is_teamowner = true;
                            }
                            else
                            {
                                rmemstatus.is_teamowner = false;
                            }
                            int event_pos = (int)ravailabilityAPI_events_ht[ravailbilityAPI.collection.items[i].data[(int)ravailibityAPI_items_ht["event_id"]].value];
                            if (reventavail.eventMemberAvailability[event_pos].memberAvailable == null)
                            {
                                reventavail.eventMemberAvailability[event_pos].memberAvailable = new ObservableCollection<MemberAvailabilityStatus>();
                            }
                            reventavail.eventMemberAvailability[event_pos].memberAvailable.Add(rmemstatus);
                        }
                        ravailabilityAPI_events_ht.Clear();
                        ravailibityAPI_items_ht.Clear();
                    }
                    for (int i = 0; i < reventavail.eventMemberAvailability.Count; i++)
                    {
                        if (rteams_ht.ContainsKey(reventavail.eventMemberAvailability[i].team_id))
                        {
                            var teams = rusers.teams[(int)rteams_ht[reventavail.eventMemberAvailability[i].team_id]];
                            Dictionary<object, int> rteamMember_ht = new Dictionary<object, int>();
                            int numOfMembersInTeam = rusers.teams[(int)rteams_ht[reventavail.eventMemberAvailability[i].team_id]].members.Count;
                            for (int j = 0; j < numOfMembersInTeam; j++)
                            {
                                rteamMember_ht.Add(rusers.teams[(int)rteams_ht[reventavail.eventMemberAvailability[i].team_id]].members[j].member_id, j);
                            }
                            for (int j = 0; j < reventavail.eventMemberAvailability[i].memberAvailable.Count; j++)
                            {
                                if (rteamMember_ht.ContainsKey(reventavail.eventMemberAvailability[i].memberAvailable[j].member_id))
                                {
                                    // int event_member_pos = (int)reventavail.eventMemberAvailability[i].memberAvailable[j].member_id;
                                    // bool tr = rteamMember_ht.Contains(event_member_pos);
                                    int member_pos = (int)rteamMember_ht[reventavail.eventMemberAvailability[i].memberAvailable[j].member_id];
                                    reventavail.eventMemberAvailability[i].memberAvailable[j].member_name = teams.members[member_pos].fullname;
                                    reventavail.eventMemberAvailability[i].memberAvailable[j].member_photo = teams.members[member_pos].member_photo;
                                }
                            }
                            rteamMember_ht.Clear();
                        }
                    }
                    
                    string res = AvailabilityAPI.eventAvailabilityDataSerializer(reventavail);
                    await mlib.writeFile("EventsMemberAvailability" + rusers.teams[teami].id, res);
                    Debug.WriteLine(res);
                }
                catch (Exception ex)
                {
                    await mlib.writeToLogFile("Exception in updateAvailability() : " + ex, true);
                }
            }
            rteams_ht.Clear();
            return true;
        }
Пример #3
0
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter == null)
     {
         parameterPresent = false;
     }
     else
     {
         parameterPresent = true;
         try
         {
             rcem = (CollectionEventAvailabilityMembers)e.Parameter;
         }
         catch (Exception ex)
         {
             ApplicationData.Current.LocalSettings.Values["currentTeamID"] = (long)e.Parameter;
             parameterPresent = false;  // it shouldn't be. But this is me trying to patch up the code instead of fixing it.
         }
     }
 }
Пример #4
0
 private void unknownGoingEmailButton_Click(object sender, RoutedEventArgs e)
 {
     CollectionEventAvailabilityMembers rcem = new CollectionEventAvailabilityMembers();
     rcem.eventid = eventid;
     rcem.team_id = teamid;
     rcem.memberAvailable = new ObservableCollection<MemberAvailabilityStatus>();
     foreach (var val in rmemUnknown)
     {
         rcem.memberAvailable.Add(val);
     }
     Frame rootFrame = Window.Current.Content as Frame;
     rootFrame.Navigate(typeof(AddNewEmail), rcem);
 }