Esempio n. 1
0
 public static NaboConfig Instance()
 {
     if (instance_ == null)
     {
         instance_ = new NaboConfig();
     }
     return(instance_);
 }
Esempio n. 2
0
        void make_meta_file()
        {
            // 生成符合纳博平台的 meta.xml 文件
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<?xml version='1.0' encoding='utf-8'?><Package><Files></Files></Package>");
            XmlElement package = doc.DocumentElement;

            XmlAttribute attr = doc.CreateAttribute("From");

            attr.Value = NaboConfig.Instance().DeviceID;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("To");
            attr.Value = NaboConfig.Instance().Teacher + '@' + NaboConfig.Instance().Domain;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("ID");
            attr.Value = Param.uuid;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("Subject");
            attr.Value = Param.subject;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("Title");
            attr.Value = NaboConfig.Instance().Title;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("Grade");
            attr.Value = NaboConfig.Instance().Grade;
            package.Attributes.Append(attr);

            attr       = doc.CreateAttribute("Teacher");
            attr.Value = NaboConfig.Instance().Teacher;
            package.Attributes.Append(attr);

            XmlNode files = doc.SelectSingleNode("/Package/Files");

            meta_add_media_files(files);

            string       meta_file_name = TaskPath + "\\meta.xml.tmp"; // XXX:上传后,再修改文件名字!
            StreamWriter sw             = new StreamWriter(meta_file_name);

            sw.Write(doc.OuterXml);
            sw.Close();
        }
Esempio n. 3
0
        /// <summary>
        /// 生成 lftp 使用的上传脚本,该脚本将在计划任务中执行
        /// </summary>
        string make_lftp_script()
        {
            // 使用 uuid.lftp 作为文件名字
            DirectoryInfo di = new DirectoryInfo(RecordingPath);
            StreamWriter  sw = new StreamWriter(ScriptFilename);

            sw.WriteLine("set ftp:charset gb2312");
            sw.WriteLine("set file:charset gb2312");
            sw.WriteLine("set ftp:passive-mode off");
            //sw.WriteLine("set net:connection-limit 1");
            //sw.WriteLine("set net:limit-total-rate 100000 100000");
            sw.WriteLine("set net:max-retries 2");
            sw.WriteLine("set net:reconnect-interval-base 2");
            sw.WriteLine("set net:reconnect-interval-max 5");
            sw.WriteLine("set mirror:set-permissions off");
            sw.WriteLine("connect " + NaboConfig.Instance().FtpPath);
            sw.WriteLine("mirror -R " + winpath_2_cygpath(TaskPath));
            sw.WriteLine("mv " + Param.uuid + "/meta.xml.tmp " + Param.uuid + "/meta.xml"); // XXX: 最后的文件名字
            sw.Close();

            return(ScriptFilename);
        }
Esempio n. 4
0
 public static NaboConfig Instance()
 {
     if (instance_ == null)
         instance_ = new NaboConfig();
     return instance_;
 }