Example #1
0
        public Setting Settings_Read()
        {
            var db = new aspnetdbEntities();

            set = db.Settings.FirstOrDefault();
            return(set);
        }
Example #2
0
        public async void GetNowMeeting()
        {
            DateTime dt1      = DateTime.Now - TimeSpan.FromMinutes(180);
            DateTime dt2      = DateTime.Now - TimeSpan.FromMinutes(165);
            var      soonmeet = databs.Meetings.Where(t => t.Start > dt1);
            var      diapmet  = soonmeet.Where(s => s.Start < dt2 && s.reminder);

            foreach (var meet in diapmet)
            {
                List <string> maillist = new List <string>();
                var           attends  = databs.MeetingAttendees.Where(m => m.MeetingID == meet.MeetingID);
                List <string> AddAtt;
                if (meet.AddAttend != null)
                {
                    AddAtt = ((meet.AddAttend.Replace(" ", "")).Split((",").ToCharArray())).ToList();
                    foreach (var adat in AddAtt)
                    {
                        maillist.Add(adat);
                    }
                }
                foreach (var attend in attends)
                {
                    var reciever = databs.AspNetUsers.FirstOrDefault(u => u.Id == attend.AttendeeID);
                    maillist.Add(reciever?.Email);
                }
                string body = String.Concat("Напоминиаем, что через ", (meet.Start - dt1).ToString(@"mm"), " минут состоится видеоконференция ", meet.Title);
                foreach (var rcpt in maillist)
                {
                    await Sendmail(rcpt, meet.Title, body, meet);

                    if (mailSent)
                    {
                        var db = new aspnetdbEntities();
                        meet.reminder = false;
                        db.Meetings.AddOrUpdate(meet);
                        db.SaveChanges();
                    }
                }
            }
        }
Example #3
0
        public List <AllVMRS.AllVmrs> GetVmrList()
        {
            All_Vmrs = new List <AllVMRS.AllVmrs>();
            aspnetdbEntities dtbs       = new aspnetdbEntities();
            List <int>       remoteInts = new List <int>();
            List <int>       localInts  = new List <int>();
            Uri       confapi           = new Uri("https://" + set.CobaMngAddress + "/api/admin/configuration/v1/conference/");
            WebClient client            = new WebClient();

            client.Credentials = new NetworkCredential(set.CobaMngLogin, set.CobaMngPass);
            client.Headers.Add("auth", "admin,ciscovoip");
            client.Headers.Add("veryfy", "False");
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            string reply  = client.DownloadString(confapi);
            string reply1 = Win1251ToUTF8(reply);

            if (!String.IsNullOrEmpty(reply))
            {
                All_VM_obj = JsonConvert.DeserializeObject <AllVMRS.VmrParent>(reply1);
                All_Vmrs   = All_VM_obj.obj;
                foreach (var vm in All_Vmrs)
                {
                    AllVmr confroom = new AllVmr();
                    remoteInts.Add(vm.id);
                    confroom.Id           = vm.id;
                    confroom.allow_guests = vm.allow_guests;
                    confroom.description  = vm.description;
                    confroom.force_presenter_into_main = vm.force_presenter_into_main;
                    confroom.guest_pin         = vm.guest_pin;
                    confroom.guest_view        = vm.guest_view;
                    confroom.host_view         = vm.host_view;
                    confroom.max_callrate_in   = vm.max_callrate_in;
                    confroom.max_callrate_out  = vm.max_callrate_out;
                    confroom.name              = vm.name;
                    confroom.participant_limit = vm.participant_limit;
                    confroom.pin          = vm.pin;
                    confroom.resource_uri = vm.resource_uri;
                    confroom.service_type = vm.service_type;
                    confroom.tag          = vm.tag;
                    dtbs.AllVmrs.AddOrUpdate(confroom);
                    try
                    {
                        foreach (var ali in vm.aliases)
                        {
                            VmrAlias alias = new VmrAlias();
                            alias.Id          = ali.id;
                            alias.alias       = ali.alias;
                            alias.description = ali.description;
                            alias.conference  = ali.conference;
                            alias.vmid        = confroom.Id;
                            dtbs.VmrAliases.AddOrUpdate(alias);
                        }

                        #region Get IVR Themes - not yet working

                        //Ivr_Themes themes = new Ivr_Themes();
                        //themes.name = vm.ivr_theme.name;
                        //themes.intid = vm.ivr_theme.id;
                        //themes.uuid = vm.ivr_theme.uuid;
                        //themes.vmid = confroom.Id;
                        //dtbs.Ivr_Themes.AddOrUpdate(themes);

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.InnerException);
                    }
                }
                foreach (var locrec in dtbs.AllVmrs)
                {
                    localInts.Add(locrec.Id);
                }
                foreach (var locint in localInts)
                {
                    if (!remoteInts.Contains(locint))
                    {
                        var delvmr   = dtbs.AllVmrs.FirstOrDefault(v => v.Id == locint);
                        var delalias = dtbs.VmrAliases.Where(a => a.vmid == delvmr.Id);
                        dtbs.VmrAliases.RemoveRange(delalias);
                        dtbs.AllVmrs.Remove(delvmr);
                        Debug.WriteLine(delvmr.name);
                    }
                }
                try
                {
                    dtbs.SaveChanges();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.InnerException);
                }
                return(All_Vmrs);
            }
            return(All_Vmrs);
        }