Ejemplo n.º 1
0
        protected void AssignDispute(object sender, DirectEventArgs e)
        {
            PhoneCall        sessionPhoneCallRecord;
            List <PhoneCall> submittedPhoneCalls;
            List <PhoneCall> userSessionPhoneCalls;

            string json = string.Empty;
            JavaScriptSerializer   serializer = new JavaScriptSerializer();
            JsonSerializerSettings settings   = new JsonSerializerSettings();

            //Get the session and sip account of the current user
            //CurrentSession = ((UserSession)HttpContext.Current.Session.Contents["UserData"]);
            sipAccount = CurrentSession.GetEffectiveSipAccount();


            //Get user phonecalls from the session
            //Handle user delegee mode and normal user mode
            userSessionPhoneCalls = CurrentSession.GetUserSessionPhoneCalls();


            json = e.ExtraParams["Values"];
            settings.NullValueHandling = NullValueHandling.Ignore;

            submittedPhoneCalls = serializer.Deserialize <List <PhoneCall> >(json);

            foreach (PhoneCall phoneCall in submittedPhoneCalls)
            {
                var sessionIdTime = phoneCall.SessionIdTime;

                sessionPhoneCallRecord = userSessionPhoneCalls.Find(
                    item => item.SessionIdTime.Year == sessionIdTime.Year &&
                    item.SessionIdTime.Month == sessionIdTime.Month &&
                    item.SessionIdTime.Day == sessionIdTime.Day &&
                    item.SessionIdTime.Hour == sessionIdTime.Hour &&
                    item.SessionIdTime.Minute == sessionIdTime.Minute &&
                    item.SessionIdTime.Second == sessionIdTime.Second);

                sessionPhoneCallRecord.UiCallType      = "Disputed";
                sessionPhoneCallRecord.UiMarkedOn      = DateTime.Now;
                sessionPhoneCallRecord.UiUpdatedByUser = sipAccount;

                Global.DATABASE.PhoneCalls.Update(sessionPhoneCallRecord, sessionPhoneCallRecord.PhoneCallsTableName);
            }

            PhoneCallsAllocationToolsMenu.Hide();

            //Reassign the user session data
            //Handle the normal user mode and user delegee mode
            CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls: userSessionPhoneCalls, userSessionAddressBook: null);

            //Rebind data to the grid store
            RebindDataToStore(userSessionPhoneCalls);
        }
Ejemplo n.º 2
0
        protected void AssignSelectedPhonecallsToMe_DirectEvent(object sender, DirectEventArgs e)
        {
            List <PhoneCall> submittedPhoneCalls;
            List <PhoneCall> userSessionPhoneCalls;

            string json = string.Empty;
            JavaScriptSerializer   serializer = new JavaScriptSerializer();
            JsonSerializerSettings settings   = new JsonSerializerSettings();

            //Get the session and sip account of the current user
            //CurrentSession = ((UserSession)HttpContext.Current.Session.Contents["UserData"]);
            sipAccount = CurrentSession.GetEffectiveSipAccount();

            //Get user phonecalls from the session
            //Handle user delegee mode and normal user mode
            userSessionPhoneCalls = CurrentSession.GetUserSessionPhoneCalls();

            json = e.ExtraParams["Values"];
            submittedPhoneCalls = serializer.Deserialize <List <PhoneCall> >(json);

            foreach (PhoneCall phoneCall in submittedPhoneCalls)
            {
                //Assign the call to this user
                phoneCall.UiAssignedToUser = sipAccount;
                phoneCall.UiCallType       = string.Empty;

                //Update this phonecall in the database
                Global.DATABASE.PhoneCalls.Update(phoneCall, phoneCall.PhoneCallsTableName);

                //Commit the changes to the grid and it's store
                ModelProxy model = DepartmentPhoneCallsStore.Find("SessionIdTime", phoneCall.SessionIdTime.ToString());

                //Remove from the Departments's phoneCalls Store
                DepartmentPhoneCallsStore.Remove(model);

                //Add it to the phonecalls store
                MyPhoneCallsGrid.GetStore().Add(phoneCall);

                //Add this new phonecall to the user session
                userSessionPhoneCalls.Add(phoneCall);
            }

            //Reload the department phonecalls grid
            DepartmentPhoneCallsGrid.GetSelectionModel().DeselectAll();

            //Reassign the user session data
            //Handle the normal user mode and user delegee mode
            CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls: userSessionPhoneCalls, userSessionAddressBook: null);

            //Rebind data to the grid store
            RebindDataToStore(userSessionPhoneCalls);
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //
            // If the user is not loggedin, redirect to Login page.
            if (HttpContext.Current.Session == null || HttpContext.Current.Session.Contents["UserData"] == null)
            {
                string RedirectTo = String.Format(@"{0}/User/PhoneCalls", Global.APPLICATION_URL);
                string Url        = String.Format(@"{0}/Login?RedirectTo={1}", Global.APPLICATION_URL, RedirectTo);
                Response.Redirect(Url);
            }
            else
            {
                CurrentSession = ((UserSession)HttpContext.Current.Session.Contents["UserData"]);
                if (CurrentSession.ActiveRoleName != Functions.NormalUserRoleName && CurrentSession.ActiveRoleName != Functions.UserDelegeeRoleName)
                {
                    string url = String.Format(@"{0}/Authorize?access={1}", Global.APPLICATION_URL, CurrentSession.ActiveRoleName);
                    Response.Redirect(url);
                }
            }

            sipAccount = CurrentSession.GetEffectiveSipAccount();
        }
Ejemplo n.º 4
0
        protected void MoveToDepartmnent(object sender, DirectEventArgs e)
        {
            PhoneCall        sessionPhoneCallRecord;
            List <PhoneCall> submittedPhoneCalls;
            List <PhoneCall> userSessionPhoneCalls;
            string           userSiteDepartment = string.Empty;

            string json = string.Empty;
            JavaScriptSerializer   serializer = new JavaScriptSerializer();
            JsonSerializerSettings settings   = new JsonSerializerSettings();

            //Get the session and sip account of the current user
            //CurrentSession = ((UserSession)HttpContext.Current.Session.Contents["UserData"]);
            sipAccount = CurrentSession.GetEffectiveSipAccount();

            //Get user phonecalls from the session
            //Handle user delegee mode and normal user mode
            userSessionPhoneCalls = CurrentSession.GetUserSessionPhoneCalls();

            json = e.ExtraParams["Values"];
            submittedPhoneCalls = serializer.Deserialize <List <PhoneCall> >(json);

            foreach (PhoneCall phoneCall in submittedPhoneCalls)
            {
                var sessionIdTime = phoneCall.SessionIdTime;

                sessionPhoneCallRecord = userSessionPhoneCalls.Find(
                    item => item.SessionIdTime.Year == sessionIdTime.Year &&
                    item.SessionIdTime.Month == sessionIdTime.Month &&
                    item.SessionIdTime.Day == sessionIdTime.Day &&
                    item.SessionIdTime.Hour == sessionIdTime.Hour &&
                    item.SessionIdTime.Minute == sessionIdTime.Minute &&
                    item.SessionIdTime.Second == sessionIdTime.Second);

                if (sessionPhoneCallRecord.UiAssignedToUser == sipAccount && !string.IsNullOrEmpty(sessionPhoneCallRecord.UiAssignedByUser))
                {
                    userSiteDepartment =
                        (CurrentSession.ActiveRoleName == Functions.UserDelegeeRoleName) ?
                        CurrentSession.DelegeeUserAccount.User.SiteName + "-" + CurrentSession.DelegeeUserAccount.User.DepartmentName :
                        CurrentSession.User.SiteName + "-" + CurrentSession.User.DepartmentName;

                    sessionPhoneCallRecord.UiCallType       = string.Empty;
                    sessionPhoneCallRecord.UiAssignedToUser = userSiteDepartment;

                    Global.DATABASE.PhoneCalls.Update(sessionPhoneCallRecord, sessionPhoneCallRecord.PhoneCallsTableName);

                    ModelProxy model = MyPhoneCallsGrid.GetStore().Find("SessionIdTime", sessionPhoneCallRecord.SessionIdTime.ToString());

                    //Remove it from the MyPhoneCallsGrid.GetStore()
                    MyPhoneCallsGrid.GetStore().Remove(model);

                    //Add it to the Departments's phoneCalls Store
                    DepartmentPhoneCallsStore.Add(phoneCall);

                    //Remove from the user own session phoneCalls list.
                    userSessionPhoneCalls.Remove(sessionPhoneCallRecord);
                }
                else
                {
                    continue;
                }
            }

            //Deselect all the grid's records
            MyPhoneCallsGrid.GetSelectionModel().DeselectAll();

            //Reassign the user session data
            //Handle the normal user mode and user delegee mode
            CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls: userSessionPhoneCalls, userSessionAddressBook: null);

            //Rebind data to the grid store
            RebindDataToStore(userSessionPhoneCalls);
        }
Ejemplo n.º 5
0
        protected void AssignAlwaysBusiness(object sender, DirectEventArgs e)
        {
            string                 json = string.Empty;
            RowSelectionModel      selectiomModel;
            JavaScriptSerializer   serializer = new JavaScriptSerializer();
            JsonSerializerSettings settings   = new JsonSerializerSettings();

            //These are used for querying the filtering the submitted phonecalls and their destinations
            PhoneBookContact        phoneBookEntry;
            List <PhoneCall>        submittedPhoneCalls;
            List <PhoneCall>        matchedDestinationCalls;
            List <PhoneBookContact> newOrUpdatedPhoneBookEntries = new List <PhoneBookContact>();

            //These would refer to either the the user's or the delegee's
            List <PhoneCall> userSessionPhoneCalls = new List <PhoneCall>();
            Dictionary <string, PhoneBookContact> userSessionAddressBook = new Dictionary <string, PhoneBookContact>();

            //Get user session and effective sip account
            //CurrentSession = ((UserSession)HttpContext.Current.Session.Contents["UserData"]);
            sipAccount = CurrentSession.GetEffectiveSipAccount();

            //Get user phoneCalls, addressbook, and phoneCallsPerPage;
            //Handle user delegee mode and normal user mode
            CurrentSession.FetchSessionPhonecallsAndAddressbookData(out userSessionPhoneCalls, out userSessionAddressBook);

            //Get the submitted grid data
            json = e.ExtraParams["Values"];
            settings.NullValueHandling = NullValueHandling.Ignore;
            selectiomModel             = this.MyPhoneCallsGrid.GetSelectionModel() as RowSelectionModel;
            submittedPhoneCalls        = serializer.Deserialize <List <PhoneCall> >(json);

            //Start allocating the submitted phone calls
            foreach (PhoneCall phoneCall in submittedPhoneCalls)
            {
                //Create a Phonebook Entry
                phoneBookEntry = new PhoneBookContact();

                //Check if this entry Already exists by either destination number and destination name (in case it's edited)
                bool found = userSessionAddressBook.ContainsKey(phoneCall.DestinationNumberUri) &&
                             (userSessionAddressBook.Values.Select(phoneBookContact => phoneBookContact.Name == phoneCall.PhoneBookName) == null ? false : true);

                if (!found)
                {
                    phoneBookEntry.Name = phoneCall.PhoneBookName ?? string.Empty;
                    phoneBookEntry.DestinationCountry = phoneCall.MarkerCallToCountry;
                    phoneBookEntry.DestinationNumber  = phoneCall.DestinationNumberUri;
                    phoneBookEntry.SipAccount         = sipAccount;
                    phoneBookEntry.Type = "Business";

                    //Add Phonebook entry to Session and to the list which will be written to database
                    if (userSessionAddressBook.ContainsKey(phoneCall.DestinationNumberUri))
                    {
                        userSessionAddressBook[phoneCall.DestinationNumberUri] = phoneBookEntry;
                    }
                    else
                    {
                        userSessionAddressBook.Add(phoneCall.DestinationNumberUri, phoneBookEntry);
                    }

                    newOrUpdatedPhoneBookEntries.Add(phoneBookEntry);
                }

                matchedDestinationCalls = userSessionPhoneCalls.Where(o => o.DestinationNumberUri == phoneCall.DestinationNumberUri && (string.IsNullOrEmpty(o.UiCallType) || o.UiCallType == "Personal")).ToList();

                foreach (PhoneCall matchedDestinationCall in matchedDestinationCalls)
                {
                    matchedDestinationCall.UiCallType      = "Business";
                    matchedDestinationCall.UiMarkedOn      = DateTime.Now;
                    matchedDestinationCall.UiUpdatedByUser = sipAccount;
                    matchedDestinationCall.PhoneBookName   = phoneCall.PhoneBookName ?? string.Empty;

                    Global.DATABASE.PhoneCalls.Update(matchedDestinationCall, matchedDestinationCall.PhoneCallsTableName);
                }
            }

            PhoneCallsAllocationToolsMenu.Hide();

            //Add To Users Addressbook Store
            Global.DATABASE.PhoneBooks.AddOrUpdatePhoneBookEntries(sipAccount, newOrUpdatedPhoneBookEntries);

            //Reassign the user session data
            //Handle the normal user mode and user delegee mode
            CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls: userSessionPhoneCalls, userSessionAddressBook: userSessionAddressBook);

            //Rebind data to the grid store
            RebindDataToStore(userSessionPhoneCalls);
        }