예제 #1
0
        public LangDic GetData(string uid)
        {
            // Stopwatch stopwatch = new Stopwatch();
            // stopwatch.Restart();
            var client     = new MongoClient();
            var db         = client.GetDatabase("LanguageDB");
            var collection = db.GetCollection <userStorage>("userStorage");

            //build dictionary by UID

            var     builder   = Builders <userStorage> .Filter;
            var     filterUID = builder.Eq("UID", uid);
            var     results   = collection.Find(filterUID).ToList();
            LangDic _langDic  = new LangDic();

            foreach (userStorage item in results)
            {
                if (item._listName != null)
                {
                    if (item._words != null)
                    {
                        _langDic.CardLists.Add(item._listName, new List <Word>(item._words.ToList()));
                    }
                    else
                    {
                        _langDic.CardLists.Add(item._listName, new List <Word>());
                    }
                }
            }
            // TimeSpan time = stopwatch.Elapsed;
            // stopwatch.Stop();

            return(_langDic);
        }
예제 #2
0
        public LangDic GetData(string uid)
        {
            LangDic langDic = _mongoConnection.GetData(uid);

            if (langDic == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(langDic);
        }
예제 #3
0
        private static void ApplyLang(object obj, LangDic dic)
        {
            var type = obj.GetType();

            foreach (var st in dic)
            {
                foreach (var fi in type.GetFields(BindingFlagAll))
                {
                    if (!dic.TryGetValue(fi.Name, out var dv))
                    {
                        continue;
                    }

                    if (dv is LangValue lv)
                    {
                        fi.SetValue(obj, lv.Value);
                    }
                    else
                    {
                        ApplyLang(fi.GetValue(obj), (LangDic)dv);
                        return;
                    }
                }

                foreach (var pi in type.GetProperties(BindingFlagAll))
                {
                    if (!dic.TryGetValue(pi.Name, out var dv))
                    {
                        continue;
                    }

                    if (dv is LangValue lv)
                    {
                        pi.SetValue(obj, lv.Value);
                    }
                    else
                    {
                        ApplyLang(pi.GetValue(obj), (LangDic)dv);
                        return;
                    }
                }
            }
        }
예제 #4
0
        private static void GenMap(JProperty jp, LangDic dic, string langCode)
        {
            // 마지막 항목인지 확인한다
            var langLevel = jp.Values().All(e => e.Values().All(ev => ev.Type == JTokenType.String));

            if (langLevel)
            {
                dic[jp.Name] = new LangValue(jp.Value[langCode].Value <string>());
            }
            else
            {
                var dicSub = new LangDic();
                dic[jp.Name] = dicSub;

                foreach (JProperty jpp in jp.Values <JObject>().Properties())
                {
                    GenMap(jpp, dicSub, langCode);
                }
            }
        }
예제 #5
0
        public void ReadMediaInfo(string inputFile)
        {
            MI.Open(inputFile);

            this.GI.fileSize = this.GetFileSize(this.MI.Get(StreamKind.General, 0, "FileSize"));
            this.GI.duration = this.GetDuration(this.MI.Get(StreamKind.General, 0, "Duration"));

            // Get video info.
            this.VI.width     = this.MI.Get(StreamKind.Video, 0, "Width");
            this.VI.height    = this.MI.Get(StreamKind.Video, 0, "Height");
            this.VI.displayAR = this.MI.Get(StreamKind.Video, 0, "DisplayAspectRatio");
            this.VI.framerate = this.MI.Get(StreamKind.Video, 0, "FrameRate") + " FPS";
            this.VI.bitrate   = this.GetBitrate(this.MI.Get(StreamKind.Video, 0, "BitRate"));

            // Switch among video codecs.
            string videoFormat = this.MI.Get(StreamKind.Video, 0, "Format");

            switch (videoFormat)
            {
            case "AVC":
                if (this.MI.Inform().Contains("x264"))
                {
                    this.VI.codec = "x264";
                }
                else
                {
                    this.VI.codec = "H.264";
                }
                break;

            case "HEVC":
                this.VI.codec = "HEVC";
                break;

            case "MPEG Video":
                this.VI.codec = "MPEG-2";
                break;

            case "VC-1":
                this.VI.codec = "VC-1";
                break;

            case "MPEG-4 Visual":
                this.VI.codec = "XviD";
                break;

            default:
                this.VI.codec = "UNKNOWN";
                break;
            }

            // Create a language name dictionary for both audio and subtitle lookup.
            LangDic languageName = new LangDic();

            this.AI = new AudioInfo[this.MI.Count_Get(StreamKind.Audio)];

            for (int i = 0; i < this.MI.Count_Get(StreamKind.Audio); i++)
            {
                // Get the language code and look it up in the dictionary.
                this.AI[i]                  = new AudioInfo(this.isSomething(this.MI.Get(StreamKind.Audio, i, "Title").ToLower(), "comm"));
                this.AI[i].audioLang        = languageName.GetFullName(this.MI.Get(StreamKind.Audio, i, "Language"));
                this.AI[i].audioCodec       = this.MI.Get(StreamKind.Audio, i, "Format");
                this.AI[i].audioChan        = this.GetChannels(this.MI.Get(StreamKind.Audio, i, "Channel(s)"));
                this.AI[i].audioBitr        = this.GetBitrate(this.MI.Get(StreamKind.Audio, i, "BitRate"));
                this.AI[i].audioCommentator = this.MI.Get(StreamKind.Audio, i, "Title");
                this.AI[i].UpdateAudioInfo();
            }

            this.SI = new SubtitleInfo[this.MI.Count_Get(StreamKind.Text)];

            for (int i = 0; i < this.MI.Count_Get(StreamKind.Text); i++)
            {
                this.SI[i]            = new SubtitleInfo();
                this.SI[i].subLang    = languageName.GetFullName(this.MI.Get(StreamKind.Text, i, "Language"));
                this.SI[i].subFormat  = this.MI.Get(StreamKind.Text, i, "Format");
                this.SI[i].subComment = this.MI.Get(StreamKind.Text, 0, "Title");
                this.SI[i].subForced  = (this.isYesOrNo(this.MI.Get(StreamKind.Text, i, "Forced")) ||
                                         this.isSomething(this.MI.Get(StreamKind.Text, i, "Title"), "Forced"));
                this.SI[i].subSDH = this.isSomething(this.MI.Get(StreamKind.Text, i, "Title"), "SDH");
                this.SI[i].UpdateSubtitleInfo();
            }
        }