public void CreateLocalizationProxy()
        {
            var template = ReadTemplate("Localization_Proxy_tmp.cshtml");
            var result   = Engine.Razor.RunCompile(template, "Localization", typeof(Dictionary <string, Dictionary <string, string> >), LocalizationMng.Sources);
            var savePath = AppPath.GetFullDirByRelativeDir(Config.OutputRelativePath);

            File.WriteAllText(savePath + "localization.js", result, System.Text.Encoding.UTF8);
        }
Exemple #2
0
        /// <summary>
        /// 保存log
        /// </summary>
        /// <param name="content"></param>
        private void SaveLog(string content)
        {
            var        logDir   = AppPath.GetFullDirByRelativeDir("Logs/");
            var        filePath = logDir + "logs.txt";
            FileStream fs       = null;

            try
            {
                lock (objLock)
                {
                    using (fs = new FileStream(filePath, FileMode.OpenOrCreate))
                    {
                        using (var sr = new StreamWriter(fs, Encoding.Default))
                        {
                            sr.WriteLine(content);
                            sr.Close();
                        }

                        var info   = new FileInfo(filePath);
                        var mbSize = info.Length / (1024 * 1024);
                        if (mbSize >= 2)
                        {
                            var files    = Directory.GetFiles(logDir);
                            var rex      = new Regex("logs([0-9]+).txt");
                            var maxCount = 0;
                            foreach (var file in files)
                            {
                                var numGroup = rex.Match(file);
                                if (numGroup.Groups.Count == 2)
                                {
                                    var count = Convert.ToInt32(numGroup.Groups[1].Value);
                                    if (count > maxCount)
                                    {
                                        maxCount = count;
                                    }
                                }
                            }
                            var newPath = logDir + string.Format("logs{0}.txt", ++maxCount);
                            info.MoveTo(newPath);
                        }
                        fs.Close();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                fs?.Close();
            }
        }
        public void CreateJsProxy(List <Type> svTypes, List <Type> itTypes)
        {
            if (svTypes == null || svTypes.Count == 0)
            {
                return;
            }
            var config = new TemplateServiceConfiguration {
                EncodedStringFactory = new RawStringFactory()
            };
            var service = RazorEngineService.Create(config);

            Engine.Razor = service;
            var template = ReadTemplate("Angular_Proxy_tmp.cshtml");
            var model    = Build(svTypes, itTypes);
            var result   = Engine.Razor.RunCompile(template, "Services", typeof(List <ServiceWithMethod>), model);
            var savePath = AppPath.GetFullDirByRelativeDir(Config.OutputRelativePath);

            File.WriteAllText(savePath + "mabp.service.ts", result, System.Text.Encoding.UTF8);
        }