Example #1
0
        public ActionResult ViewGroup(long?id)
        {
            var        objProfile = _repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId);
            GroupModel objGroup   = new GroupModel();

            if (objProfile != null)
            {
                long profileId = objProfile.Id;
                //objGroup = GroupMap.Map(_repoGroup.GetSingle(x => x.CreatedBy == profileId && x.Id == id));
                objGroup             = GroupMap.Map(_repoGroup.GetSingle(x => x.Id == id));
                objGroup.UserProfile = new UserProfileModel();
                objGroup.UserProfile = UserProfileMap.Map(_repoUserProfile.GetSingle(x => x.Id == objGroup.CreatedBy));
            }

            ViewBag.CurrentMainTab     = "Front";
            ViewBag.CurrentSubTab      = "Group";
            ViewBag.CurrentSuperSubTab = "Name";
            ViewBag.DisciplineName     = _repoDiscipline.GetSingle(x => x.Id == objGroup.DisciplineId).DisciplineName;
            ViewBag.ProvinceName       = _repoProvince.GetSingle(x => x.Id == objGroup.ProvinceId).NAME_1;

            var objEntityFile = _repoEntityFile.GetSingle(x => x.EntityId == objGroup.Id && x.Section.SectionName == "groups");

            if (objEntityFile != null)
            {
                ViewBag.FileId = objEntityFile.FileId.GetValueOrDefault();
            }

            return(View(objGroup));
        }
Example #2
0
 private void editChannelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ListView.SelectedIndexCollection indexes = listView1.SelectedIndices;
     if (indexes.Count == 0)
     {
         return;
     }
     for (int i = indexes.Count - 1; i >= 0; i--)
     {
         int index = indexes[i];
         if (index >= 0 && index < listView1.Items.Count)
         {
             ListViewItem    item    = listView1.Items[index];
             GroupMap        map     = (GroupMap)item.Tag;
             Channel         channel = map.ReferencedChannel();
             FormEditChannel dlg     = new FormEditChannel();
             dlg.Channel = channel;
             dlg.ShowDialog();
             listView1.Items[indexes[0]].Text             = channel.DisplayName;
             listView1.Items[indexes[0]].SubItems[1].Text = channel.ChannelNumber.ToString();
             return;
         }
     }
     ReOrder();
 }
Example #3
0
 public BadgeData(GroupMap groupMap, LocationMap locationMap, string badgeData)
 {
     _groupMap    = groupMap;
     _locationMap = locationMap;
     Parse(badgeData);
     _swipeList.Process();
 }
Example #4
0
        public ActionResult AjaxGetGroupById(int Id)
        {
            GroupModel           objGroup    = GroupMap.Map(_repoGroup.GetSingle(x => x.Id == Id));
            List <ProvinceModel> lstProvince = new List <ProvinceModel>();

            lstProvince = ProvinceMap.Map(_repoProvince.GetList(x => x.Country == objGroup.CountryName).ToList());
            return(Json(new { status = "success", group = objGroup, lstProvince = lstProvince.ToArray() }));
        }
Example #5
0
        public ActionResult ViewGroup(long?id)
        {
            GroupModel objGroup = new GroupModel();

            objGroup = GroupMap.Map(_repoGroup.GetSingle(x => x.Id == id));
            ViewBag.CurrentMainTab     = "Front";
            ViewBag.CurrentSubTab      = "Group";
            ViewBag.CurrentSuperSubTab = "Name";
            ViewBag.DisciplineName     = _repoDiscipline.GetSingle(x => x.Id == objGroup.DisciplineId).DisciplineName;
            ViewBag.ProvinceName       = _repoProvince.GetSingle(x => x.Id == objGroup.ProvinceId).NAME_1;
            var objEntityFile = _repoEntityFile.GetSingle(x => x.EntityId == objGroup.Id && x.Section.SectionName == "groups");

            if (objEntityFile != null)
            {
                ViewBag.FileId = objEntityFile.FileId.GetValueOrDefault();
            }

            //for comment
            long profileId = 0;

            if (CurrentUser != null)
            {
                var objProfile = _repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId);
                if (objProfile != null)
                {
                    profileId = objProfile.Id;
                }
            }
            ViewData["ProfileId"] = profileId;
            ViewData["Url"]       = Request.RawUrl;
            ViewData["EntityId"]  = id;
            ViewData["SectionId"] = 2;

            var objFavourite = _repoFavourite.GetSingle(x => x.SectionId == 2 && x.EntityId == id);

            if (objFavourite != null)
            {
                objGroup.isFavourite = true;
            }
            else
            {
                objGroup.isFavourite = false;
            }


            //--------------
            return(View(objGroup));
        }
        public PartialViewResult userContentList(string name, string countryName, int?provinceId, int?disciplineId, string sex, int?categoryId, int?sortOrder, int?pageNumber = null, int?itemsPerPage = null)
        {
            int publicationListCount = 0;
            int groupListCount       = 0;
            int offset = 0;

            offset = (((int)pageNumber - 1) * (int)itemsPerPage);

            List <GroupModel> lstGroups = GroupMap.Map(_repoGroup.GetList(x => x.CreatedBy == 25).ToList());

            groupListCount = lstGroups.Count();

            List <PublicationModel> lstPublication = PublicationMap.Map(_repoPublication.GetList(x => x.CreatedBy == 25).ToList());

            publicationListCount = lstPublication.Count();

            foreach (var item in lstGroups.ToList())
            {
                var objEntityFile = _repoEntityFile.GetSingle(x => x.EntityId == item.Id && x.Section.SectionName == "Groups");
                if (objEntityFile != null)
                {
                    item.FileId = objEntityFile.FileId;
                }
                lstGroups.Add(item);
            }

            //foreach (var item in lstPublication.ToList())
            //{
            //    var objEntityFile = _repoEntityFile.GetSingle(x => x.EntityId == item.Id && x.Section.SectionName == "Groups");
            //    if (objEntityFile != null)
            //    {
            //        item.FileId = objEntityFile.FileId;
            //    }
            //    lstGroups.Add(item);
            //}
            ViewBag.TotalCount = groupListCount + publicationListCount;

            ViewBag.PagedListofPublication = lstPublication ?? new List <PublicationModel>();
            ViewBag.PagedListofGroups      = lstGroups ?? new List <GroupModel>();

            return(PartialView("_UserContentList"));
        }
Example #7
0
        static object _Read(GridNode node)
        {
            var groups = node.Head
                         .Select((v, y) => (y: y + 1, v))
                         .Where(t => t.v != "")
                         .GroupBy(t => t.v)
                         .Select(g => SimpleGroup.From(g.Select(t => t.y), Sym.From(g.Key)))
                         .ToArray();

            var map = groups.Aggregate(
                Map <int, Sym> .Empty,
                (m, g) => m.Add(GroupMap.Lift(g.Nodes, g.Value)));

            if (node.Tail != null)
            {
                var right = Read(node.Tail).As <Map <int, Sym> >();
                map = map.Add(right);
            }

            return(map);
        }
Example #8
0
        PivotTableGroup GetOrCreateGroup(IGroup group)
        {
            if (group.Key == null)
            {
                if (NullKeyGroup == null)
                {
                    NullKeyGroup = new PivotTableGroup(group, Aggregators, group.SortOrder);
                    GroupList.Add(NullKeyGroup);
                }
                return(NullKeyGroup);
            }
            PivotTableGroup result;

            if (GroupMap.TryGetValue(group.Key, out result))
            {
                return(result);
            }
            result = new PivotTableGroup(group, Aggregators, group.SortOrder);
            GroupList.Add(result);
            GroupMap[group.Key] = result;
            return(result);
        }
Example #9
0
        //Create a GroupMap
        private async Task CreateGroupMapAsync(string ServerKey, string messageChannelKey)
        {
            ServerChannel serverChannel = await _Context.ServerChannels.FindAsync(ServerKey);

            MessageChannel messageChannel = await _Context.messageChannels.FindAsync(messageChannelKey);

            // Check , that they both exist
            if (messageChannel == null || serverChannel == null)
            {
                return;
            }
            //Get the users who have joined the server
            IEnumerable <ServerChannelMap> maps = _Context.serverChannelMaps.Select(val => val).Where(pre => pre.ServerChannelKey == ServerKey);
            List <GroupMap> groupMaps           = new List <GroupMap>(); //Map them to the group

            foreach (var m in maps)
            {
                GroupMap gmap = new GroupMap {
                    Key               = Guid.NewGuid().ToString(),
                    UserId            = m.UserId,
                    MessageChannelKey = messageChannelKey,
                    ServerName        = serverChannel.Name,
                };
                groupMaps.Add(gmap);
            }
            try
            {
                await _Context.GroupMaps.AddRangeAsync(groupMaps);

                await _Context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e); // Change it to log later
            }
        }
Example #10
0
        public PartialViewResult groupList(string groupName, long?createdBy, int?pageNumber = null, int?itemsPerPage = null)
        {
            int listCount = 0;
            int offset    = 0;

            offset = (((int)pageNumber - 1) * (int)itemsPerPage);
            List <GroupModel> lstGroup         = new List <GroupModel>();
            List <GroupModel> lstNewGroupModel = new List <GroupModel>();


            if (!string.IsNullOrEmpty(groupName))
            {
                lstGroup  = GroupMap.Map(_repoGroup.GetList(x => x.Title == groupName && x.Status == (int)Status.Active).OrderBy(x => x.CreatedDate).Skip(offset).Take((int)itemsPerPage).ToList());
                listCount = _repoGroup.GetList(x => x.Title == groupName && x.Status == (int)Status.Active).ToList().Count;
            }
            else
            {
                lstGroup  = GroupMap.Map(_repoGroup.GetList(x => x.Status == (int)Status.Active).OrderBy(x => x.CreatedDate).Skip(offset).Take((int)itemsPerPage).ToList());
                listCount = _repoGroup.GetList(x => x.Status == (int)Status.Active).ToList().Count;
            }

            ViewBag.PagedListofUsers = lstGroup ?? new List <GroupModel>();
            ViewBag.TotalUserCount   = listCount;

            foreach (var item in lstGroup.ToList())
            {
                var objEntityFile = _repoEntityFile.GetSingle(x => x.EntityId == item.Id && x.Section.SectionName == "groups");
                if (objEntityFile != null)
                {
                    item.FileId = objEntityFile.FileId;
                }
                lstNewGroupModel.Add(item);
            }

            return(PartialView("_visitorsGroupList", lstNewGroupModel));
        }
        private void importButton_Click(object sender, EventArgs e)
        {
            bool importtv          = imCheckTvChannels.Checked;
            bool importtvgroups    = imCheckTvGroups.Checked;
            bool importradio       = imCheckRadioChannels.Checked;
            bool importradiogroups = imCheckRadioGroups.Checked;
            bool importschedules   = imCheckSchedules.Checked;

            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.DefaultExt       = "xml";
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.Title            = "Load channels, channel groups and schedules";
            openFileDialog1.InitialDirectory = String.Format(@"{0}\Team MediaPortal\MediaPortal TV Server",
                                                             Environment.GetFolderPath(
                                                                 Environment.SpecialFolder.CommonApplicationData));
            openFileDialog1.FileName     = "export.xml";
            openFileDialog1.AddExtension = true;
            openFileDialog1.Multiselect  = false;
            if (openFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            NotifyForm dlg = new NotifyForm("Importing tv channels...", "This can take some time\n\nPlease be patient...");

            try
            {
                dlg.Show();
                dlg.WaitForDisplay();
                CountryCollection collection = new CountryCollection();
                TvBusinessLayer   layer      = new TvBusinessLayer();
                bool mergeChannels           = false; // every exported channel will be imported on its own.
                int  channelCount            = 0;
                int  scheduleCount           = 0;
                int  tvChannelGroupCount     = 0;
                int  radioChannelGroupCount  = 0;

                if (layer.Channels.Count > 0 && (importtv || importradio))
                {
                    // rtv: we could offer to set a "merge" property here so tuningdetails would be updated for existing channels.
                    if (
                        MessageBox.Show(
                            "Existing channels detected! \nIf you continue to import your old backup then all identically named channels will be treated equal - there is a risk of duplicate entries. \nDo you really want to go on?",
                            "Channels found", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        return;
                    }
                    else
                    {
                        mergeChannels = true;
                    }
                }

                XmlDocument doc = new XmlDocument();
                Log.Info("TvChannels: Trying to import channels from {0}", openFileDialog1.FileName);
                doc.Load(openFileDialog1.FileName);
                XmlNodeList channelList           = doc.SelectNodes("/tvserver/channels/channel");
                XmlNodeList tvChannelGroupList    = doc.SelectNodes("/tvserver/channelgroups/channelgroup");
                XmlNodeList radioChannelGroupList = doc.SelectNodes("/tvserver/radiochannelgroups/radiochannelgroup");
                XmlNodeList scheduleList          = doc.SelectNodes("/tvserver/schedules/schedule");
                if (channelList != null)
                {
                    foreach (XmlNode nodeChannel in channelList)
                    {
                        try
                        {
                            Channel     dbChannel;
                            XmlNodeList tuningList   = nodeChannel.SelectNodes("TuningDetails/tune");
                            XmlNodeList mappingList  = nodeChannel.SelectNodes("mappings/map");
                            bool        grabEpg      = (GetNodeAttribute(nodeChannel, "GrabEpg", "True") == "True");
                            bool        isRadio      = (GetNodeAttribute(nodeChannel, "IsRadio", "False") == "True");
                            bool        isTv         = (GetNodeAttribute(nodeChannel, "IsTv", "True") == "True");
                            DateTime    lastGrabTime = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "LastGrabTime", "01.01.1900"),
                                                                           "yyyy-M-d H:m:s", CultureInfo.InvariantCulture);
                            int      sortOrder        = Int32.Parse(GetNodeAttribute(nodeChannel, "SortOrder", "0"));
                            int      timesWatched     = Int32.Parse(GetNodeAttribute(nodeChannel, "TimesWatched", "0"));
                            DateTime totalTimeWatched =
                                DateTime.ParseExact(GetNodeAttribute(nodeChannel, "TotalTimeWatched", "01.01.1900"), "yyyy-M-d H:m:s",
                                                    CultureInfo.InvariantCulture);
                            bool   visibileInGuide = (GetNodeAttribute(nodeChannel, "VisibleInGuide", "True") == "True");
                            bool   FreeToAir       = (GetNodeAttribute(nodeChannel, "FreeToAir", "True") == "True");
                            string displayName     = GetNodeAttribute(nodeChannel, "DisplayName", "Unkown");

                            // Only import TV or radio channels if the corresponding checkbox was checked
                            if ((isTv && !importtv) || (isRadio && !importradio))
                            {
                                continue;
                            }

                            channelCount++;

                            // rtv: since analog allows NOT to merge channels we need to take care of this. US users e.g. have multiple stations named "Sport" with different tuningdetails.
                            // using AddChannel would incorrectly "merge" these totally different channels.
                            // see this: http://forum.team-mediaportal.com/1-0-rc1-svn-builds-271/importing-exported-channel-list-groups-channels-39368/
                            Log.Info("TvChannels: Adding {0}. channel: {1}", channelCount, displayName);
                            IList <Channel> foundExistingChannels = layer.GetChannelsByName(displayName);
                            if (mergeChannels && (foundExistingChannels != null && foundExistingChannels.Count > 0))
                            {
                                dbChannel = foundExistingChannels[0];
                            }
                            else
                            {
                                dbChannel = layer.AddNewChannel(displayName);
                            }

                            dbChannel.GrabEpg          = grabEpg;
                            dbChannel.IsRadio          = isRadio;
                            dbChannel.IsTv             = isTv;
                            dbChannel.LastGrabTime     = lastGrabTime;
                            dbChannel.SortOrder        = sortOrder;
                            dbChannel.TimesWatched     = timesWatched;
                            dbChannel.TotalTimeWatched = totalTimeWatched;
                            dbChannel.VisibleInGuide   = visibileInGuide;
                            dbChannel.DisplayName      = displayName;
                            dbChannel.Persist();

                            //
                            // chemelli: When we import channels we need to add those to the "AllChannels" group
                            //
                            if (isTv)
                            {
                                layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
                            }
                            else
                            {
                                layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
                            }

                            foreach (XmlNode nodeMap in mappingList)
                            {
                                int     idCard   = Int32.Parse(nodeMap.Attributes["IdCard"].Value);
                                XmlNode nodeCard =
                                    doc.SelectSingleNode(String.Format("/tvserver/servers/server/cards/card[@IdCard={0}]", idCard));
                                Card dbCard = layer.GetCardByDevicePath(nodeCard.Attributes["DevicePath"].Value);
                                if (dbCard != null)
                                {
                                    layer.MapChannelToCard(dbCard, dbChannel, false);
                                }
                            }
                            foreach (XmlNode nodeTune in tuningList)
                            {
                                int    bandwidth          = Int32.Parse(nodeTune.Attributes["Bandwidth"].Value);
                                int    channelNumber      = Int32.Parse(nodeTune.Attributes["ChannelNumber"].Value);
                                int    channelType        = Int32.Parse(nodeTune.Attributes["ChannelType"].Value);
                                int    countryId          = Int32.Parse(nodeTune.Attributes["CountryId"].Value);
                                int    diseqc             = Int32.Parse(nodeTune.Attributes["Diseqc"].Value);
                                bool   fta                = (nodeTune.Attributes["FreeToAir"].Value == "True");
                                int    frequency          = Int32.Parse(nodeTune.Attributes["Frequency"].Value);
                                int    majorChannel       = Int32.Parse(nodeTune.Attributes["MajorChannel"].Value);
                                int    minorChannel       = Int32.Parse(nodeTune.Attributes["MinorChannel"].Value);
                                int    modulation         = Int32.Parse(nodeTune.Attributes["Modulation"].Value);
                                string name               = nodeTune.Attributes["Name"].Value;
                                int    networkId          = Int32.Parse(nodeTune.Attributes["NetworkId"].Value);
                                int    pmtPid             = Int32.Parse(nodeTune.Attributes["PmtPid"].Value);
                                int    polarisation       = Int32.Parse(nodeTune.Attributes["Polarisation"].Value);
                                string provider           = GetNodeAttribute(nodeTune, "Provider", "");
                                int    serviceId          = Int32.Parse(nodeTune.Attributes["ServiceId"].Value);
                                int    switchingFrequency = Int32.Parse(nodeTune.Attributes["SwitchingFrequency"].Value);
                                int    symbolrate         = Int32.Parse(nodeTune.Attributes["Symbolrate"].Value);
                                int    transportId        = Int32.Parse(nodeTune.Attributes["TransportId"].Value);
                                int    tuningSource       = Int32.Parse(GetNodeAttribute(nodeTune, "TuningSource", "0"));
                                int    videoSource        = Int32.Parse(GetNodeAttribute(nodeTune, "VideoSource", "0"));
                                int    audioSource        = Int32.Parse(GetNodeAttribute(nodeTune, "AudioSource", "0"));
                                bool   isVCRSignal        = (GetNodeAttribute(nodeChannel, "IsVCRSignal", "False") == "True");
                                int    SatIndex           = Int32.Parse(GetNodeAttribute(nodeTune, "SatIndex", "-1"));
                                int    InnerFecRate       = Int32.Parse(GetNodeAttribute(nodeTune, "InnerFecRate", "-1"));
                                int    band               = Int32.Parse(GetNodeAttribute(nodeTune, "Band", "0"));
                                int    pilot              = Int32.Parse(GetNodeAttribute(nodeTune, "Pilot", "-1"));
                                int    rollOff            = Int32.Parse(GetNodeAttribute(nodeTune, "RollOff", "-1"));
                                string url                = GetNodeAttribute(nodeTune, "Url", "");
                                int    bitrate            = Int32.Parse(GetNodeAttribute(nodeTune, "Bitrate", "0"));

                                switch (channelType)
                                {
                                case 0: //AnalogChannel
                                    AnalogChannel analogChannel = new AnalogChannel();
                                    analogChannel.ChannelNumber = channelNumber;
                                    analogChannel.Country       = collection.Countries[countryId];
                                    analogChannel.Frequency     = frequency;
                                    analogChannel.IsRadio       = isRadio;
                                    analogChannel.IsTv          = isTv;
                                    analogChannel.Name          = name;
                                    analogChannel.TunerSource   = (TunerInputType)tuningSource;
                                    analogChannel.AudioSource   = (AnalogChannel.AudioInputType)audioSource;
                                    analogChannel.VideoSource   = (AnalogChannel.VideoInputType)videoSource;
                                    analogChannel.IsVCRSignal   = isVCRSignal;
                                    layer.AddTuningDetails(dbChannel, analogChannel);
                                    Log.Info("TvChannels: Added tuning details for analog channel: {0} number: {1}", name, channelNumber);
                                    break;

                                case 1: //ATSCChannel
                                    ATSCChannel atscChannel = new ATSCChannel();
                                    atscChannel.MajorChannel    = majorChannel;
                                    atscChannel.MinorChannel    = minorChannel;
                                    atscChannel.PhysicalChannel = channelNumber;
                                    atscChannel.FreeToAir       = fta;
                                    atscChannel.Frequency       = frequency;
                                    atscChannel.IsRadio         = isRadio;
                                    atscChannel.IsTv            = isTv;
                                    atscChannel.Name            = name;
                                    atscChannel.NetworkId       = networkId;
                                    atscChannel.PmtPid          = pmtPid;
                                    atscChannel.Provider        = provider;
                                    atscChannel.ServiceId       = serviceId;
                                    atscChannel.TransportId     = transportId;
                                    atscChannel.ModulationType  = (ModulationType)modulation;
                                    layer.AddTuningDetails(dbChannel, atscChannel);
                                    Log.Info("TvChannels: Added tuning details for ATSC channel: {0} number: {1} provider: {2}", name,
                                             channelNumber, provider);
                                    break;

                                case 2: //DVBCChannel
                                    DVBCChannel dvbcChannel = new DVBCChannel();
                                    dvbcChannel.ModulationType       = (ModulationType)modulation;
                                    dvbcChannel.FreeToAir            = fta;
                                    dvbcChannel.Frequency            = frequency;
                                    dvbcChannel.IsRadio              = isRadio;
                                    dvbcChannel.IsTv                 = isTv;
                                    dvbcChannel.Name                 = name;
                                    dvbcChannel.NetworkId            = networkId;
                                    dvbcChannel.PmtPid               = pmtPid;
                                    dvbcChannel.Provider             = provider;
                                    dvbcChannel.ServiceId            = serviceId;
                                    dvbcChannel.SymbolRate           = symbolrate;
                                    dvbcChannel.TransportId          = transportId;
                                    dvbcChannel.LogicalChannelNumber = channelNumber;
                                    layer.AddTuningDetails(dbChannel, dvbcChannel);
                                    Log.Info("TvChannels: Added tuning details for DVB-C channel: {0} provider: {1}", name, provider);
                                    break;

                                case 3: //DVBSChannel
                                    DVBSChannel dvbsChannel = new DVBSChannel();
                                    dvbsChannel.DisEqc             = (DisEqcType)diseqc;
                                    dvbsChannel.Polarisation       = (Polarisation)polarisation;
                                    dvbsChannel.SwitchingFrequency = switchingFrequency;
                                    dvbsChannel.FreeToAir          = fta;
                                    dvbsChannel.Frequency          = frequency;
                                    dvbsChannel.IsRadio            = isRadio;
                                    dvbsChannel.IsTv                 = isTv;
                                    dvbsChannel.Name                 = name;
                                    dvbsChannel.NetworkId            = networkId;
                                    dvbsChannel.PmtPid               = pmtPid;
                                    dvbsChannel.Provider             = provider;
                                    dvbsChannel.ServiceId            = serviceId;
                                    dvbsChannel.SymbolRate           = symbolrate;
                                    dvbsChannel.TransportId          = transportId;
                                    dvbsChannel.SatelliteIndex       = SatIndex;
                                    dvbsChannel.ModulationType       = (ModulationType)modulation;
                                    dvbsChannel.InnerFecRate         = (BinaryConvolutionCodeRate)InnerFecRate;
                                    dvbsChannel.BandType             = (BandType)band;
                                    dvbsChannel.Pilot                = (Pilot)pilot;
                                    dvbsChannel.Rolloff              = (RollOff)rollOff;
                                    dvbsChannel.LogicalChannelNumber = channelNumber;
                                    layer.AddTuningDetails(dbChannel, dvbsChannel);
                                    Log.Info("TvChannels: Added tuning details for DVB-S channel: {0} provider: {1}", name, provider);
                                    break;

                                case 4: //DVBTChannel
                                    DVBTChannel dvbtChannel = new DVBTChannel();
                                    dvbtChannel.BandWidth            = bandwidth;
                                    dvbtChannel.FreeToAir            = fta;
                                    dvbtChannel.Frequency            = frequency;
                                    dvbtChannel.IsRadio              = isRadio;
                                    dvbtChannel.IsTv                 = isTv;
                                    dvbtChannel.Name                 = name;
                                    dvbtChannel.NetworkId            = networkId;
                                    dvbtChannel.PmtPid               = pmtPid;
                                    dvbtChannel.Provider             = provider;
                                    dvbtChannel.ServiceId            = serviceId;
                                    dvbtChannel.TransportId          = transportId;
                                    dvbtChannel.LogicalChannelNumber = channelNumber;
                                    layer.AddTuningDetails(dbChannel, dvbtChannel);
                                    Log.Info("TvChannels: Added tuning details for DVB-T channel: {0} provider: {1}", name, provider);
                                    break;

                                case 5: //Webstream
                                    layer.AddWebStreamTuningDetails(dbChannel, url, bitrate);
                                    break;

                                case 7: //DVBIPChannel
                                    DVBIPChannel dvbipChannel = new DVBIPChannel();
                                    dvbipChannel.FreeToAir            = fta;
                                    dvbipChannel.Frequency            = frequency;
                                    dvbipChannel.IsRadio              = isRadio;
                                    dvbipChannel.IsTv                 = isTv;
                                    dvbipChannel.LogicalChannelNumber = channelNumber;
                                    dvbipChannel.Name                 = name;
                                    dvbipChannel.NetworkId            = networkId;
                                    dvbipChannel.PmtPid               = pmtPid;
                                    dvbipChannel.Provider             = provider;
                                    dvbipChannel.ServiceId            = serviceId;
                                    dvbipChannel.TransportId          = transportId;
                                    dvbipChannel.Url = url;
                                    layer.AddTuningDetails(dbChannel, dvbipChannel);
                                    Log.Info("TvChannels: Added tuning details for DVB-IP channel: {0} provider: {1}", name, provider);
                                    break;
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                            Log.Error("TvChannels: Failed to add channel - {0}", exc.Message);
                        }
                    }
                }

                if (tvChannelGroupList != null && importtvgroups)
                {
                    // Import tv channel groups
                    foreach (XmlNode nodeChannelGroup in tvChannelGroupList)
                    {
                        try
                        {
                            tvChannelGroupCount++;
                            string       groupName      = nodeChannelGroup.Attributes["GroupName"].Value;
                            int          groupSortOrder = Int32.Parse(nodeChannelGroup.Attributes["SortOrder"].Value);
                            ChannelGroup group          = null;
                            if (groupName == TvConstants.TvGroupNames.AllChannels)
                            {
                                group = layer.GetGroupByName(groupName) ??
                                        new ChannelGroup(groupName, groupSortOrder);
                            }
                            else
                            {
                                group = layer.GetGroupByName(groupName, groupSortOrder) ??
                                        new ChannelGroup(groupName, groupSortOrder);
                            }
                            group.Persist();
                            XmlNodeList mappingList = nodeChannelGroup.SelectNodes("mappings/map");
                            foreach (XmlNode nodeMap in mappingList)
                            {
                                IList <Channel> channels  = layer.GetChannelsByName(nodeMap.Attributes["ChannelName"].Value);
                                int             sortOrder = Int32.Parse(GetNodeAttribute(nodeMap, "SortOrder", "9999"));
                                if (channels != null && channels.Count > 0)
                                {
                                    Channel channel = channels[0];
                                    if (!channel.GroupNames.Contains(group.GroupName))
                                    {
                                        GroupMap map = new GroupMap(group.IdGroup, channel.IdChannel, sortOrder);
                                        map.Persist();
                                    }
                                    else
                                    {
                                        foreach (GroupMap map in channel.ReferringGroupMap())
                                        {
                                            if (map.IdGroup == group.IdGroup)
                                            {
                                                map.SortOrder = sortOrder;
                                                map.Persist();
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception exg)
                        {
                            Log.Error("TvChannels: Failed to add group - {0}", exg.Message);
                        }
                    }
                }

                if (radioChannelGroupList != null && importradiogroups)
                {
                    // Import radio channel groups
                    foreach (XmlNode nodeChannelGroup in radioChannelGroupList)
                    {
                        try
                        {
                            radioChannelGroupCount++;
                            string            groupName      = nodeChannelGroup.Attributes["GroupName"].Value;
                            int               groupSortOrder = Int32.Parse(nodeChannelGroup.Attributes["SortOrder"].Value);
                            RadioChannelGroup group          = layer.GetRadioChannelGroupByName(groupName) ??
                                                               new RadioChannelGroup(groupName, groupSortOrder);
                            group.Persist();
                            XmlNodeList mappingList = nodeChannelGroup.SelectNodes("mappings/map");
                            foreach (XmlNode nodeMap in mappingList)
                            {
                                IList <Channel> channels  = layer.GetChannelsByName(nodeMap.Attributes["ChannelName"].Value);
                                int             sortOrder = Int32.Parse(GetNodeAttribute(nodeMap, "SortOrder", "9999"));
                                if (channels != null && channels.Count > 0)
                                {
                                    Channel channel = channels[0];
                                    if (!channel.GroupNames.Contains(group.GroupName))
                                    {
                                        RadioGroupMap map = new RadioGroupMap(group.IdGroup, channel.IdChannel, sortOrder);
                                        map.Persist();
                                    }
                                    else
                                    {
                                        foreach (RadioGroupMap map in channel.ReferringRadioGroupMap())
                                        {
                                            if (map.IdGroup == group.IdGroup)
                                            {
                                                map.SortOrder = sortOrder;
                                                map.Persist();
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception exg)
                        {
                            Log.Error("Radio Channels: Failed to add group - {0}", exg.Message);
                        }
                    }
                }

                if (scheduleList != null && importschedules)
                {
                    // Import schedules
                    foreach (XmlNode nodeSchedule in scheduleList)
                    {
                        try
                        {
                            int idChannel = -1;

                            string programName = nodeSchedule.Attributes["ProgramName"].Value;
                            string channel     = nodeSchedule.Attributes["ChannelName"].Value;
                            if (!string.IsNullOrEmpty(channel))
                            {
                                IList <Channel> channels = layer.GetChannelsByName(channel);
                                if (channels != null && channels.Count > 0)
                                {
                                    idChannel = channels[0].IdChannel;
                                }
                            }
                            DateTime startTime = DateTime.ParseExact(nodeSchedule.Attributes["StartTime"].Value, "yyyy-M-d H:m:s",
                                                                     CultureInfo.InvariantCulture);
                            DateTime endTime = DateTime.ParseExact(nodeSchedule.Attributes["EndTime"].Value, "yyyy-M-d H:m:s",
                                                                   CultureInfo.InvariantCulture);
                            int      scheduleType = Int32.Parse(nodeSchedule.Attributes["ScheduleType"].Value);
                            Schedule schedule     = layer.AddSchedule(idChannel, programName, startTime, endTime, scheduleType);

                            schedule.ScheduleType = scheduleType;
                            schedule.KeepDate     = DateTime.ParseExact(nodeSchedule.Attributes["KeepDate"].Value, "yyyy-M-d H:m:s",
                                                                        CultureInfo.InvariantCulture);
                            schedule.PreRecordInterval  = Int32.Parse(nodeSchedule.Attributes["PreRecordInterval"].Value);
                            schedule.PostRecordInterval = Int32.Parse(nodeSchedule.Attributes["PostRecordInterval"].Value);
                            schedule.Priority           = Int32.Parse(nodeSchedule.Attributes["Priority"].Value);
                            schedule.Quality            = Int32.Parse(nodeSchedule.Attributes["Quality"].Value);
                            schedule.Directory          = nodeSchedule.Attributes["Directory"].Value;
                            schedule.KeepMethod         = Int32.Parse(nodeSchedule.Attributes["KeepMethod"].Value);
                            schedule.MaxAirings         = Int32.Parse(nodeSchedule.Attributes["MaxAirings"].Value);
                            schedule.RecommendedCard    = Int32.Parse(nodeSchedule.Attributes["RecommendedCard"].Value);
                            schedule.ScheduleType       = Int32.Parse(nodeSchedule.Attributes["ScheduleType"].Value);
                            schedule.Series             = (GetNodeAttribute(nodeSchedule, "Series", "False") == "True");
                            if (idChannel > -1)
                            {
                                schedule.Persist();
                                scheduleCount++;
                                Log.Info("TvChannels: Added schedule: {0} on channel: {1}", programName, channel);
                            }
                            else
                            {
                                Log.Info("TvChannels: Skipped schedule: {0} because the channel was unknown: {1}", programName, channel);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("TvChannels: Failed to add schedule - {0}", ex.Message);
                        }
                    }
                }

                dlg.Close();
                Log.Info(
                    "TvChannels: Imported {0} channels, {1} tv channel groups, {2} radio channel groups and {3} schedules",
                    channelCount, tvChannelGroupCount, radioChannelGroupCount, scheduleCount);
                MessageBox.Show(
                    String.Format("Imported {0} channels, {1} tv channel groups, {2} radio channel groups and {3} schedules",
                                  channelCount, tvChannelGroupCount, radioChannelGroupCount, scheduleCount));
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error while importing:\n\n" + ex + " " + ex.StackTrace);
            }
            finally
            {
                dlg.Close();
                OnSectionActivated();
            }
        }
Example #12
0
        public ActionResult Groups(GroupModel objGroup)
        {
            ViewBag.DisciplineId = new SelectList(_repoDiscipline.GetList().ToList(), "Id", "DisciplineName", "");
            if (objGroup.DisciplineId == 0)
            {
                TempData[LeonniConstants.ErrorMessage] = " Please Select Any Discipline";
                return(View(objGroup));
            }
            else if (objGroup.CountryName == "Country")
            {
                TempData[LeonniConstants.ErrorMessage] = " Please Select Any Country";
                return(View(objGroup));
            }
            if (objGroup.ProvinceId == 0)
            {
                TempData[LeonniConstants.ErrorMessage] = " Please Select Any State";
                return(View(objGroup));
            }
            else
            {
                try
                {
                    Group newGroup = null;

                    if (ModelState.IsValid)
                    {
                        if (objGroup != null)
                        {
                            if (objGroup.IsNew == true)
                            {
                                objGroup.CreatedDate = DateTime.Now;
                                if (_repoUserProfile != null)
                                {
                                    objGroup.CreatedBy = _repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId).Id;
                                }
                                objGroup.IsDeleted   = false;
                                objGroup.Status      = (int)Status.Active;
                                objGroup.UserProfile = UserProfileMap.Map(_repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId));
                                newGroup             = GroupMap.Map(objGroup);
                                _repoGroup.Add(newGroup);
                                objGroup.IsNew = false;
                            }
                            else
                            {
                                if (objGroup.GroupPic != null)
                                {
                                    var entityFileModel = _repoEntityFile.GetSingle(x => x.SectionId == 2 && x.EntityId == objGroup.Id);
                                    if (entityFileModel != null)
                                    {
                                        var fileModel = _repoFile.GetSingle(x => x.Id == entityFileModel.FileId);
                                        if (fileModel != null)
                                        {
                                            _repoFile.Delete(fileModel);
                                            _repoFile.Save();
                                        }

                                        _repoEntityFile.Delete(entityFileModel);
                                        _repoEntityFile.Save();
                                    }
                                }
                                objGroup.IsDeleted = false;
                                objGroup.Status    = (int)Status.Active;
                                _repoGroup.Update(GroupMap.Map(objGroup));
                            }

                            _repoGroup.Save();


                            if (objGroup.GroupPic != null && objGroup.GroupPic.InputStream != null)
                            {
                                var file = new Models.File();

                                file.ContentType = objGroup.GroupPic.ContentType;
                                file.FileName    = objGroup.GroupPic.FileName;

                                var memoryStream = new MemoryStream();
                                objGroup.GroupPic.InputStream.CopyTo(memoryStream);

                                file.Content = memoryStream.ToArray();
                                //file.UserId = group.UserId;

                                if (file.Content == null)
                                {
                                    TempData[LeonniConstants.ErrorMessage] = "Please upload Photo";
                                    return(View(objGroup)); // RedirectToAction("Create");
                                }

                                _repoFile.Add(file);
                                _repoFile.Save();

                                EntityFileModel efModel    = new EntityFileModel();
                                var             entityFile = EntityFileMap.Map(efModel);
                                entityFile.SectionId = _repoSection.GetSingle(x => x.SectionName == "Groups").Id;

                                if (objGroup.Id != 0)
                                {
                                    entityFile.EntityId = objGroup.Id;
                                }
                                else
                                {
                                    entityFile.EntityId = newGroup.Id;
                                }
                                entityFile.FileId = file.Id;
                                _repoEntityFile.Add(entityFile);
                                _repoEntityFile.Save();
                            }
                        }
                        else
                        {
                            TempData[LeonniConstants.ErrorMessage] = " Update Unsuccessful";
                            return(View(objGroup));
                        }
                        TempData[LeonniConstants.SuccessMessage] = "Group Updated Successfully";
                        return(RedirectToAction("Groups"));
                    }
                    return(View(objGroup));
                    //TempData[LeonniConstants.SuccessMessage] = " Update Successful";
                    //return RedirectToAction("Groups", new { model = objGroup });
                }
                catch (Exception e)
                {
                    TempData[LeonniConstants.ErrorMessage] = e.ToString();
                    return(View(objGroup));
                }
            }
        }