Example #1
0
        public List <ModelSoundItem> GetListSoundItemByChuyen(int idChuyen)
        {
            List <ModelSoundItem> listItem = null;

            try
            {
                string    sqlReadConfig = "Select Id from SOUND_ReadConfig where IdChuyen=" + idChuyen + " and IsActive=1 and IsDeleted=0";
                DataTable dtReadConfig  = dbclass.TruyVan_TraVe_DataTable(sqlReadConfig);
                if (dtReadConfig != null && dtReadConfig.Rows.Count > 0)
                {
                    foreach (DataRow row in dtReadConfig.Rows)
                    {
                        int       idConfig            = int.Parse(row["Id"].ToString());
                        string    sqlReadConfigDetail = "Select IntType, IdSound, IdIntConfig from SOUND_ReadConfigDetail where IdReadConfig=" + idConfig + " and IsActive=1 and IsDeleted=0 order by OrderIndex ASC";
                        DataTable dtReadConfigDetail  = dbclass.TruyVan_TraVe_DataTable(sqlReadConfigDetail);
                        if (dtReadConfigDetail != null && dtReadConfigDetail.Rows.Count > 0)
                        {
                            listItem = new List <ModelSoundItem>();
                            foreach (DataRow rowDetail in dtReadConfigDetail.Rows)
                            {
                                ModelSoundItem item    = new ModelSoundItem();
                                int            intType = 0;
                                int.TryParse(rowDetail["IntType"].ToString(), out intType);
                                item.FileType = intType;
                                if (intType == 0)
                                {
                                    int idIntConfig = 0;
                                    int.TryParse(rowDetail["IdIntConfig"].ToString(), out idIntConfig);
                                    string formula = soundIntConfigDAO.GetFormulaById(idIntConfig);
                                    if (!string.IsNullOrEmpty(formula))
                                    {
                                        formula      = formula.Replace('[', ' ');
                                        formula      = formula.Replace(']', ' ');
                                        item.Formula = formula;
                                    }
                                }
                                else
                                {
                                    int idSound = 0;
                                    int.TryParse(rowDetail["IdSound"].ToString(), out idSound);
                                    string path = soundDAO.GetPathById(idSound);
                                    if (!string.IsNullOrEmpty(path))
                                    {
                                        item.SoundPath = path;
                                    }
                                }
                                listItem.Add(item);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listItem);
        }
Example #2
0
        public static List <ModelSoundItem> GetListSoundItemByChuyen(int idChuyen, int configType)
        {
            var returnList = new List <ModelSoundItem>();

            try
            {
                var db  = new PMSEntities();
                var cfs = db.SOUND_ReadConfigDetail.Where(x => !x.IsDeleted && !x.SOUND_ReadConfig.IsDeleted && x.IsActive && x.SOUND_ReadConfig.IsActive && x.SOUND_ReadConfig.IdChuyen == idChuyen && x.SOUND_ReadConfig.ConfigType == configType).OrderBy(x => x.OrderIndex).ToList();
                if (cfs != null && cfs.Count > 0)
                {
                    var soundInts = db.SOUND_IntConfig.Where(x => !x.IsDeleted && x.IsActive).ToList();
                    var sounds    = db.SOUNDs.ToList();
                    foreach (var item in cfs)
                    {
                        var soundItem = new ModelSoundItem();
                        soundItem.FileType = item.IntType;
                        if (item.IntType == 0)
                        {
                            var intCF = soundInts.FirstOrDefault(x => x.Id == item.IdIntConfig);
                            if (intCF != null)
                            {
                                soundItem.Formula        = intCF.Formula;
                                soundItem.IsProductivity = intCF.IsProductivity;
                            }
                        }
                        else
                        {
                            var s = sounds.FirstOrDefault(x => x.Id == item.IdSound);
                            soundItem.SoundPath = s != null ? s.Path : string.Empty;
                        }
                        returnList.Add(soundItem);
                    }
                }
            }
            catch (Exception)
            { }
            return(returnList);
        }