コード例 #1
0
 public ConfigurationCenterRegistryProvider(IMicropartOfConfigurationCenter configurationCenterRegistry)
 {
     _configurationCenterRegistry = configurationCenterRegistry;
     Data      = new Dictionary <string, string>();
     _keyEntry = SingletonUtil.Singleton <KeyEntry <T> > .Instance;
     _fileName = Path.Combine(AppPath.GetAppConfigurationPath(), _keyEntry.FileName);
 }
コード例 #2
0
        public JsonResult SavePath(AppPath appPath)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    if (string.IsNullOrEmpty(appPath.AppPathId))
                    {
                        dbLMenu.SavePath(appPath, System.Web.HttpContext.Current.User.Identity.GetUserId());
                    }
                    else
                    {
                        dbLMenu.UpdatePath(appPath, System.Web.HttpContext.Current.User.Identity.GetUserId());
                    }
                }


                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var error = ex.Message.ToString();
                return(Json(new { success = false, SaveError = "Error" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        static public string GetPath(AppPath pathType)
        {
            string result = "";

            switch (pathType)
            {
            case AppPath.basePath:
                result = GetBaseAppPath();
                break;

            case AppPath.testSource:
                result = Path.Combine(GetBaseAppPath(), "..", "..", "..", "..", "UnitTest.Commands", "source");
                break;

            case AppPath.testRules:    //Packrules default output use
                result = Path.Combine(GetBaseAppPath(), "..", "..", "..", "..", "UnitTest.Commands", "customrules");
                break;

            case AppPath.testOutput:    //Packrules default output use
                result = Path.Combine(GetBaseAppPath(), "..", "..", "..", "..", "UnitTest.Commands", "output");
                break;
            }

            result = Path.GetFullPath(result);
            return(result);
        }
コード例 #4
0
        public AppPath ViewContent(string AppPathId)
        {
            var results = (from app in context.AppPaths
                           where app.AppPathId == AppPathId
                           select new
            {
                app.AppPathId,
                app.AppPathName,
                app.Description,
                app.PagePath,
                app.Parameters,
                app.IsDelete,
                app.CreateDt,
                app.CreateId,
                app.UpdateDt,
                app.UpdateId
            }).FirstOrDefault();


            var viweModel = new AppPath
            {
                AppPathId   = results.AppPathId,
                AppPathName = results.AppPathName,
                Description = results.Description,
                PagePath    = results.PagePath,
                Parameters  = results.Parameters,
                IsDelete    = results.IsDelete,
                CreateDt    = results.CreateDt,
                CreateId    = results.CreateId,
                UpdateDt    = results.UpdateDt,
                UpdateId    = results.UpdateId
            };

            return(viweModel);
        }
コード例 #5
0
        /// <summary>
        /// 获取SmartCodeApp
        /// </summary>
        /// <param name="slnType">解决方案类型</param>
        /// <param name="item">代码生成项</param>
        private static SmartCodeApp GetSmartCodeApp(int slnType, CodeGenItem item)
        {
            var buildSettings = "";

            switch (slnType)
            {
            case 1:
                buildSettings = "BingSlnGenerateConfig.yml";
                break;

            case 2:
                buildSettings = "BingCodeGenerateConfig.yml";
                break;
            }

            var app = new SmartCodeAppBuilder().Build(AppPath.Relative(buildSettings));

            app.Project.Module = item.SlnName;
            app.Project.DataSource.Parameters["DbName"]           = item.DbName;
            app.Project.DataSource.Parameters["DbProvider"]       = item.DbProvider;
            app.Project.DataSource.Parameters["ConnectionString"] = item.DbConnectionString;
            app.Project.Output.Path = item.OutputPath;
            app.Project.Parameters["UnitOfWork"] = item.UnitOfWorkName;
            return(app);
        }
コード例 #6
0
 public Lesson(Guid id, string name, int lessonNumber, AppPath appPath, string description,
               string contentUrl, Guid?dependentOnLessonId, bool newFeature, string questionField,
               int correctAnswer, string answer1, string answer2, string answer3, string answer4,
               string answer5, string answer6, LessonType type, bool published = false, bool enabled = false)
 {
     Id                  = id;
     Name                = name;
     LessonNumber        = lessonNumber;
     AppPath             = appPath;
     Description         = description;
     Published           = published;
     ContentURL          = contentUrl;
     DependentOnLessonId = dependentOnLessonId;
     NewFeature          = newFeature;
     QuestionField       = questionField;
     CorrectAnswer       = correctAnswer;
     Answer1             = answer1;
     Answer2             = answer2;
     Answer3             = answer3;
     Answer4             = answer4;
     Answer5             = answer5;
     Answer6             = answer6;
     Enabled             = enabled;
     Type                = type;
     NewFeature          = newFeature;
 }
コード例 #7
0
 public void AddChild(Application app)
 {
     // appPath is null if app is invalid (e.g. path: .../(apps)/browse
     var appPath = AppPath.MakePath(app.Path);
     if (appPath != null)
         AddChild(app, appPath, 1);
 }
コード例 #8
0
        private List <Application> GetApplicationsInternal(string appName, NodeHead head, string scenarioName, string requestedDevice)
        {
            if (head == null || RootAppNode == null)
            {
                return(new List <Application>());
            }

            var device = requestedDevice == null
                ? new string[0]
                : DeviceManager.GetDeviceChain(requestedDevice.ToLowerInvariant()) ?? new string[0];

            var appPath = AppPath.MakePath(head, appName, device);

            if (appPath == null)
            {
                return(EmptyApplicationList);
            }

            var lastNode = SearchLastNode(appPath);

            if (appName != null)
            {
                return(GetApplicationsByAppName(lastNode, appPath));
            }
            return(GetApplicationsByScenario(lastNode, appPath, scenarioName, device));
        }
コード例 #9
0
            private void AddChild(Application app, AppPath appPath, int pathIndex)
            {
                if (pathIndex < 0)
                {
                    return;
                }
                var name        = appPath.Indices[pathIndex];
                var appNodeType = appPath.AppNodeTypes[pathIndex];

                if (pathIndex < appPath.Indices.Length - 1)
                {
                    AppNode child = null;
                    foreach (var pathChild in this.Children)
                    {
                        if (pathChild.Name == name && pathChild.AppNodeType == appNodeType)
                        {
                            child = (AppNode)pathChild;
                            break;
                        }
                    }
                    var nextIndex = appPath.GetNextIndex(pathIndex);
                    if (child == null)
                    {
                        child = new AppNode(name, appNodeType, this);
                    }
                    child.AddChild(app, appPath, nextIndex);
                }
                else
                {
                    var child = new AppNode(name, appNodeType, this, app);
                }
            }
コード例 #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddOptions();
            services.Configure <Project>(Configuration.GetSection("Project"));
            services.Configure <MenuRoot>(Configuration.GetSection("MenuRoot"));


            IFileProvider fileProvider = new PhysicalFileProvider(AppPath.Relative("Templates"));

            services.Configure <RazorViewEngineOptions>(options =>
            {
                options.FileProviders.Clear();
                options.FileProviders.Add(fileProvider);
            });

            services.AddLogging(builder => builder
                                .AddConfiguration(Configuration.GetSection("Logging"))
                                .AddConsole());

            services.AddTransient <OfficialRazorViewToStringRenderer>();

            services.AddSingleton <ITemplateEngine, OfficialRazorTemplateEngine>();
            services.AddSingleton <AddNewBussinessHelper>();
            services.AddScoped <IProjectBuilder, ProjectBuilder>();
            services.AddAutoMapper();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
コード例 #11
0
        static public string GetPath(AppPath pathType)
        {
            string result = "";

            switch (pathType)
            {
            case AppPath.basePath:
                result = GetBaseAppPath();
                break;

            case AppPath.defaultLog:
                result = Path.Combine(GetBaseAppPath(), "log.txt");
                break;

            case AppPath.defaultRules:
                result = Path.Combine(GetBaseAppPath(), "rules", "default");
                break;

            case AppPath.tagGroupPref:
                result = Path.Combine(GetBaseAppPath(), "preferences", "tagreportgroups.json");
                break;

            case AppPath.tagCounterPref:
                result = Path.Combine(GetBaseAppPath(), "preferences", "tagcounters.json");
                break;
            }

            return(result);
        }
コード例 #12
0
        private void GetApplicationsInType(AppNode typeNode, AppPath appPath, string scenario, string[] device, Dictionary<int, Application> allApps)
        {
            foreach (var child in typeNode.Children)
            {
                if (child.AppNodeType == AppNodeType.Action)
                {
                    var search = true;
                    Application existingApp;
                    if (allApps.TryGetValue(child.Name, out existingApp))
                        if (existingApp.Clear || !existingApp.IsOverride)
                            search = false;

                    if (search)
                    {
                        // deepest device
                        var lastDeviceNode = SearchLastNode(child, appPath, appPath.ActionIndex + 1, true);
                        var app = SearchAppInAction(lastDeviceNode, appPath, scenario);
                        if (app != null)
                        {
                            if (existingApp == null)
                            {
                                allApps.Add(child.Name, app);
                            }
                            else
                            {
                                app = Override(app, existingApp);
                                allApps[child.Name] = app;
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
        private List<Application> GetApplicationsByScenario(AppNode lastNode, AppPath appPath, string scenarioName, string[] device)
        {
            // resolve all applications filtered by scenario
            var apps = new Dictionary<int, Application>();

            while (lastNode != null)
            {
                if (lastNode.AppNodeType == AppNodeType.Type)
                {
                    GetApplicationsInType(lastNode, appPath, scenarioName, device, apps);
                }

                // parent typelevel or pathlevel
                if (lastNode.Name == PathSegmentThisIndex)
                    lastNode = SearchLastNode(lastNode.Parent, appPath, appPath.TypeIndex, false);
                else if (lastNode.AppNodeType == AppNodeType.Type)
                    lastNode = SearchLastNode(lastNode.Parent, appPath, appPath.ActionIndex, true);
                else
                    lastNode = SearchLastNode(lastNode.Parent, appPath, appPath.TypeIndex, true);
            }
            var result = apps.Values.ToList();
            for (int i = result.Count - 1; i >= 0; i--)
                if (result[i].Clear || result[i].IsOverride)
                    result.RemoveAt(i);

            result.Sort(new ApplicationComparer());
            return result;
        }
コード例 #14
0
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmReleaseBuild_Load(object sender, EventArgs e)
        {
            try
            {
                //1.读取配置文件
                string xmlDirPath  = AppPath.GetRootRelative("Configs//Tabs");
                var    listConfigs = rbh.GetTabsByDir(xmlDirPath);
                if (listConfigs.Count > 0)
                {
                    //动态生成Tab项
                    foreach (var item in listConfigs)
                    {
                        var tempTabConfig = item.TabConfig;
                        _tabConfigList.Add(tempTabConfig.Name, item);
                        TabPage page = new TabPage
                        {
                            Text = tempTabConfig.Name,
                            Name = tempTabConfig.Name,
                        };

                        tabReleaseList.TabPages.Add(page);
                    }

                    //刷新默认选中的tab数据
                    LoadTabData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载失败,请检查配置文件中的获取语句是否可以正确执行!\n异常信息:" + ex.Message);
            }
        }
コード例 #15
0
        public static string GetPath(AppPath pathType)
        {
            string result = "";

            switch (pathType)
            {
            case AppPath.basePath:
                result = GetBaseAppPath();
                break;

            case AppPath.defaultLog:
                result = Path.Combine(GetBaseAppPath(), "log.txt");
                break;

            case AppPath.defaultRulesSrc:                                                                                              //Packrules source use
                result = Path.GetFullPath(Path.Combine(GetBaseAppPath(), "..", "..", "..", "..", "AppInspector", "rules", "default")); //used to ref project folder
                break;

            case AppPath.defaultRulesPackedFile:                                                                                      //Packrules default output use
                result = Path.Combine(GetBaseAppPath(), "..", "..", "..", "..", "AppInspector", "Resources", "defaultRulesPkd.json"); //packed default file in project resources
                break;

            case AppPath.tagGroupPref:    //CLI use only
                result = Path.Combine(GetBaseAppPath(), "preferences", "tagreportgroups.json");
                break;

            case AppPath.tagCounterPref:    //CLI use only
                result = Path.Combine(GetBaseAppPath(), "preferences", "tagcounters.json");
                break;
            }

            result = Path.GetFullPath(result);
            return(result);
        }
コード例 #16
0
        public FeedFileData GetFeedFileByStore(Store store, string secondFileName = null, string extension = null)
        {
            if (store == null)
            {
                return(null);
            }

            string dirTemp  = AppPath.TempDir();
            string ext      = extension ?? BaseSettings.ExportFormat;
            string dir      = Path.Combine(HttpRuntime.AppDomainAppPath, "Content\\files\\exportimport");
            string fileName = "{0}_{1}".FormatWith(store.Id, BaseSettings.StaticFileName);
            string logName  = Path.GetFileNameWithoutExtension(fileName) + ".txt";

            if (ext.HasValue())
            {
                fileName = Path.GetFileNameWithoutExtension(fileName) + (ext.StartsWith(".") ? "" : ".") + ext;
            }

            string url = "{0}content/files/exportimport/".FormatWith(store.Url.EnsureEndsWith("/"));

            if (!(url.StartsWith("http://") || url.StartsWith("https://")))
            {
                url = "http://" + url;
            }

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var feedFile = new FeedFileData
            {
                StoreId      = store.Id,
                StoreName    = store.Name,
                FileTempPath = Path.Combine(dirTemp, fileName),
                FilePath     = Path.Combine(dir, fileName),
                FileUrl      = url + fileName,
                LogPath      = Path.Combine(dir, logName),
                LogUrl       = url + logName
            };

            try
            {
                feedFile.LastWriteTime = File.GetLastWriteTimeUtc(feedFile.FilePath).RelativeFormat(true, null);
            }
            catch (Exception)
            {
                feedFile.LastWriteTime = feedFile.LastWriteTime.NaIfEmpty();
            }

            if (secondFileName.HasValue())
            {
                string fname2 = store.Id + "_" + secondFileName;
                feedFile.CustomProperties.Add("SecondFileTempPath", Path.Combine(dirTemp, fname2));
                feedFile.CustomProperties.Add("SecondFilePath", Path.Combine(dir, fname2));
                feedFile.CustomProperties.Add("SecondFileUrl", url + fname2);
            }
            return(feedFile);
        }
コード例 #17
0
        public void ExportToExcel(HttpContext context, string reportName, bool Compress)
        {
            string     xlsPath = AppPath.PhysicalPath(SiteUrls.Instance.Paths["ExcelTemplate"]);
            FileStream fs      =
                new FileStream(xlsPath, FileMode.Open, FileAccess.Read);

            HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true);

            var style = templateWorkbook.CreateCellStyle();

            SetCellStyle(style);
            HSSFSheet sheet = templateWorkbook.GetSheet("Sheet1");

            //HSSFAnchor a

            sheet.DefaultColumnWidth = 20;
            int       cellIndex = 1;
            const int startRow  = 3;

            GenerateReportName(sheet, reportName);
            GenerateHeader(sheet, templateWorkbook, startRow, cellIndex);
            int i = 0;

            foreach (var listValue in _listValues)
            {
                cellIndex = 1;
                HSSFRow row = sheet.CreateRow(startRow + ++i);
                foreach (var o in listValue)
                {
                    var cell = row.CreateCell(cellIndex++);
                    if (o != null)
                    {
                        cell.SetCellValue(o.ToString());
                    }
                    else
                    {
                        cell.SetCellValue("");
                    }
                    cell.CellStyle = style;
                }
            }

            MemoryStream ms = new MemoryStream();

            templateWorkbook.Write(ms);
            if (Compress)
            {
                ToCompress(context, templateWorkbook.GetBytes());
                return;
            }
            //ToCompress(templateWorkbook.GetBytes());
            DateTime d        = DateTime.Now;
            string   filename = string.Format("ExcelReport{0}_{1}_{2}_{3}_{4}.xls", d.Year, d.Month, d.Day, d.Hour, d.Minute);

            context.Response.AddHeader("Content-disposition", "attachment; filename=" + filename);
            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.BinaryWrite(ms.GetBuffer());
            context.Response.End();
        }
コード例 #18
0
            public static AppPath MakePath(string path)
            {
                var words       = path.Split(_pathSeparatorChars, StringSplitOptions.RemoveEmptyEntries).ToList();
                var result      = new List <int>();
                var typeIndex   = -1;
                var actionIndex = -1;
                var isType      = false;
                var i           = 0;

                while (i < words.Count)
                {
                    var word = words[i];
                    if (isType)
                    {
                        // remove current word and insert words of type path
                        if (word != "This")
                        {
                            var ntype = Providers.Instance.StorageSchema.NodeTypes[word];
                            if (ntype == null)
                            {
                                return(null);
                            }
                            var typeNames = ntype.NodeTypePath.Split('/');
                            words.RemoveAt(i);
                            words.InsertRange(i, typeNames);
                            word        = words[i];
                            actionIndex = i + typeNames.Length;
                        }
                        else
                        {
                            actionIndex = i + 1;
                        }
                        isType = false;
                    }
                    word = word.ToLowerInvariant();
                    if (word == AppFolderName)
                    {
                        typeIndex = i;
                        isType    = true;
                        words.RemoveAt(i);
                        continue;
                    }

                    var index = PathSegments.IndexOf(word);
                    if (index < 0)
                    {
                        index = PathSegments.Count;
                        PathSegments.Add(word);
                    }
                    result.Add(index);
                    i++;
                }
                var appPath = new AppPath {
                    Indices = result.ToArray(), TypeIndex = typeIndex, ActionIndex = actionIndex
                };

                appPath.Initialize();
                return(appPath);
            }
コード例 #19
0
ファイル: TemplateManager.cs プロジェクト: goupviet/MiniAbp
        public static void GenerateLocalization(LocalizationManager localizationManager)
        {
            var template = ReadTemplate("LocalizationTemplate.cshtml");
            var result   = Engine.Razor.RunCompile(template, "Localization", typeof(Dictionary <string, Dictionary <string, string> >), localizationManager.Sources);
            var savePath = AppPath.GetRelativeDir("Content\\Lib\\miniAbp\\auto\\");

            File.WriteAllText(savePath + "localization.js", result, Encoding.UTF8);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
            public static AppPath MakePath(NodeHead head, string actionName, string[] device)
            {
                var actionNameIndex = -1;
                if (actionName != null)
                {
                    actionName = actionName.ToLowerInvariant();
                    actionNameIndex = PathSegments.IndexOf(actionName);
                    if (actionNameIndex < 0)
                        return null;
                }

                var words = head.Path.Split(_pathSeparatorChars, StringSplitOptions.RemoveEmptyEntries).ToList();
                for (int i = 0; i < words.Count; i++)
                    words[i] = words[i].ToLowerInvariant();

                var result = new List<int>();
                var typeIndex = -1;
                var actionIndex = -1;
                var isTruncated = false;
                foreach (var word in words)
                {
                    var index = PathSegments.IndexOf(word);
                    if (index < 0)
                    {
                        isTruncated = true;
                        break;
                    }
                    result.Add(index);
                }
                typeIndex = result.Count;

                var ntype = ActiveSchema.NodeTypes.GetItemById(head.NodeTypeId);
                var typeNames = ntype.NodeTypePath.Split('/');
                foreach (var typeName in typeNames)
                {
                    var index = PathSegments.IndexOf(typeName.ToLowerInvariant());
                    if (index < 0)
                        break;
                    result.Add(index);
                }

                actionIndex = result.Count;
                result.Add(actionNameIndex); // can be -1
                if (device != null)
                {
                    for (int i = device.Length - 1; i >= 0; i--)
                    {
                        var index = PathSegments.IndexOf(device[i]);
                        if (index < 0)
                            break;
                        result.Add(index);
                    }
                }

                var appPath = new AppPath { Indices = result.ToArray(), TypeIndex = typeIndex, ActionIndex = actionIndex, Truncated = isTruncated };
                appPath.Initialize();
                return appPath;
            }
コード例 #22
0
        private AppNode SearchLastNode(AppNode appNode, AppPath appPath, int pathIndex, bool thisEnabled)
        {
            if (appNode == null)
            {
                return(null);
            }

            if (pathIndex >= appPath.Indices.Length)
            {
                return(appNode);
            }

            if (!appPath.Truncated && pathIndex == appPath.TypeIndex && appNode.Level == pathIndex - 1 && thisEnabled)
            {
                foreach (var child in appNode.Children)
                {
                    if (child.Name == PathSegmentThisIndex)
                    {
                        if (appPath.Indices[appPath.ActionIndex] < 0)
                        {
                            return(child);
                        }
                        var thisNode = child;
                        var last     = SearchLastNode(thisNode, appPath, appPath.ActionIndex, thisEnabled);
                        if (last != null)
                        {
                            return(last);
                        }
                    }
                }
            }

            var name        = appPath.Indices[pathIndex];
            var appNodeType = appPath.AppNodeTypes[pathIndex];

            if (name < 0)
            {
                return(appNode);
            }

            foreach (var child in appNode.Children)
            {
                if (child.Name == name && child.AppNodeType == appNodeType)
                {
                    return(SearchLastNode(child, appPath, pathIndex + 1, thisEnabled));
                }
            }

            if (pathIndex < appPath.TypeIndex)
            {
                return(SearchLastNode(appNode, appPath, appPath.TypeIndex, thisEnabled));
            }
            if (pathIndex < appPath.ActionIndex)
            {
                return(SearchLastNode(appNode, appPath, appPath.ActionIndex, thisEnabled));
            }
            return(appNode);
        }
コード例 #23
0
 public Application(AppId application,
                    AppUrl url,
                    AppPath path,
                    AppMode mode)
 {
     ApplicationId = application;
     Url           = url;
     Path          = path;
     Mode          = mode;
 }
コード例 #24
0
        public void Post(UploadFile uploadFile)
        {
            WriteBinaryToFile($"{AppPath.GetAiDirectory()}\\{uploadFile.FileName}", uploadFile.Content);
            var aiInfo = new AiInfo()
            {
                DisplayName = uploadFile.DisplayName, FileName = uploadFile.FileName
            };
            var aiInfoRepository = new AiInfoRepository();

            aiInfoRepository.Save(aiInfo);
        }
コード例 #25
0
        public void SaveAs(string path)
        {
            if (!AppPath.IsPathDirectoryExists(path))
            {
                throw new Exception("Directory is not exists, " + path);
            }
            FileStream fs = new FileStream(path, FileMode.Create);

            fs.Write(FileBytes, 0, ContentLength);
            fs.Close();
        }
コード例 #26
0
        public void New_AppPath_Should_Be_A_Valid_Path()
        {
            // Arrange
            string path = Environment.CurrentDirectory;

            // Act
            AppPath appPath = new AppPath(path);

            // Assert
            Assert.Equal(path, appPath.ToString());
        }
コード例 #27
0
 public static void Init(string startupDir, string appDataDir, string postfix)
 {
     AppPath.startupDir   = startupDir;
     AppPath.appDataDir   = appDataDir;
     AppPath.templatesDir = Path.Combine(startupDir, Templates);
     AppPath.syntaxDir    = new AppPath(Syntax, null);
     AppPath.syntaxDtd    = new AppPath(Path.Combine(Syntax, "language.dtd"), null);
     AppPath.schemesDir   = new AppPath(Schemes, null);
     AppPath.snippetsDir  = new AppPath(Snippets, null);
     AppPath.configPath   = new AppPath("tw-config.xml", !string.IsNullOrEmpty(postfix) ? "tw-config-" + postfix + ".xml" : null);
 }
コード例 #28
0
        public static XmlDocument GetXmlFromByte(byte[] bytes)
        {
            string file = DateTime.Now.Date.Ticks.ToString();

            file = AppPath.PhysicalPath(file);
            File.WriteAllBytes(file, bytes);
            var xml = new XmlDocument();

            xml.Load(file);
            File.Delete(file);
            return(xml);
        }
コード例 #29
0
 public Section(Guid id, string name, int sectionNumber, AppPath appPath, string description,
                SectionType type, List <Course> courses, bool featured = false)
 {
     Id            = id;
     Name          = name;
     SectionNumber = sectionNumber;
     AppPath       = appPath;
     Description   = description;
     Type          = type;
     Featured      = featured;
     Courses       = courses;
 }
コード例 #30
0
ファイル: FileLogger.cs プロジェクト: goupviet/MiniAbp
        /// <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();
            }
        }