예제 #1
0
        public void SaveFileInfo()
        {
            if (frequencies.Count == 0)
            {
                return;                         // An empty or unsupported file
            }
            Dictionary <string, object> nameValueData = new Dictionary <string, object>();

            nameValueData.Add("file_name", fileName);
            nameValueData.Add("words_count", wordsCount);
            nameValueData.Add("unique_words_count", frequencies.Count);
            nameValueData.Add("characters_count", charactersCount);
            nameValueData.Add("category", getCategoryIndex());
            nameValueData.Add("created_at", Utils.GetCurrentDateTime());

            fileId = DbHelper.InsertReq("wf_files", nameValueData);
            if (fileId != -1)
            {
                List <Dictionary <string, object> > data = new List <Dictionary <string, object> >();
                foreach (xWordFrequencies xwf in frequencies)
                {
                    nameValueData = new Dictionary <string, object>();
                    nameValueData.Add("file_id", fileId);
                    nameValueData.Add("word", xwf.word);
                    nameValueData.Add("rank", xwf.rank);
                    nameValueData.Add("frequency", xwf.frequency);
                    nameValueData.Add("percentage", xwf.percentage);
                    data.Add(nameValueData);
                }
                DbHelper.InsertWithTransaction("wf_frequencies", data);
                isProcessed = true;
            }
            else
            {
                isProcessed = false;
            }
            // Ok
        }