コード例 #1
0
ファイル: server.cs プロジェクト: markdebruyn/SECTH
        public void ReadData(ClientInfo ci, String text)
        {
            string []         textList           = text.Split(new string[] { ";;;" }, StringSplitOptions.RemoveEmptyEntries);
            CommunicationFile commnunicationFile = new CommunicationFile(textList[0], Convert.ToDateTime(textList[1]), textList[2], textList[3]);

            //hereunder shalt be forged the translation component
            LoggerRaw.WriteLog(commnunicationFile);
            List <CommunicationFile> communicationFileList = textTranslationService.Translate(commnunicationFile);


            foreach (CommunicationFile item in communicationFileList) /* translate the inhoud van het bericht en veranderen taal naar vertaalde taal hierboven doen
                                                                       *  communicationfile is een list van allen communicationfiles die overeenkomen met elke taal*/
            {
                if (item.Language == "en")
                {
                    Logger.WriteLog(item);
                }
                server.Broadcast(item.ConvertToByteArray());
            }
        }
コード例 #2
0
        public List <CommunicationFile> Translate(CommunicationFile communicationFile)
        {
            List <CommunicationFile> communicationFileList = new List <CommunicationFile>();

            string[] languageList = { "en", "de", "nl", "ja", "es", "hi", "ar", "zh-CHS" };
            foreach (string lang in languageList)
            {
                string language;
                if (lang == "zh-CHS")
                {
                    language = "zh";
                }
                else
                {
                    language = lang;
                }
                CommunicationFile newCommunicationFile = new CommunicationFile(language, communicationFile.WriteTime, communicationFile.Author, Translate(lang, communicationFile.Message));
                communicationFileList.Add(newCommunicationFile);
            }
            return(communicationFileList);
        }
コード例 #3
0
 public void WriteLog(CommunicationFile communication)
 {
     using (StreamWriter logWriter = File.AppendText(filepath))
         logWriter.Write(communication.WriteTime + ", " + communication.Language + ": " + communication.Author + ": " + communication.Message + Environment.NewLine);
 }