コード例 #1
0
        /// <summary>
        /// 创建项目
        /// </summary>
        public void createProject()
        {
            String name = getTextBox("txtName").Text.Trim();
            String path = getTextBox("txtPath").Text.Trim();

            if (name == null || name.Length == 0)
            {
                MessageBox.Show("请输入项目名称!", "提示");
                return;
            }
            if (path == null || path.Length == 0)
            {
                MessageBox.Show("请输入项目路径!", "提示");
                return;
            }
            List <FCGridRow> selectedRows = m_gridTemplate.SelectedRows;
            int selectedRowsSize          = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                String identifier = selectedRows[0].getCell(1).getString();
                if (identifier != null && identifier.Length > 0)
                {
                    String        identifier2 = selectedRows[0].getCell(2).getString();
                    String        identifier3 = selectedRows[0].getCell(3).getString();
                    String        identifier4 = selectedRows[0].getCell(4).getString();
                    DirectoryInfo dir         = new DirectoryInfo(DataCenter.GetAppPath());
                    String        codeDir     = Application.StartupPath + "\\config\\projects\\" + identifier + "\\" + identifier2 + "\\" + identifier3;
                    if (identifier4 == "0")
                    {
                        ArrayList <String> files = new ArrayList <String>();
                        FCFile.getFiles(codeDir, files);
                        int filesSize = files.Count;
                        if (filesSize > 0)
                        {
                            String fullName = files.get(0);
                            String suffix   = fullName.Substring(fullName.LastIndexOf('.') + 1);
                            String newPath  = path + "\\" + name + "." + suffix;
                            File.Copy(fullName, newPath, true);
                            m_designer.openFile(newPath);
                        }
                    }
                    else if (identifier4 == "1")
                    {
                        String projectDir = path + "\\" + name;
                        createProject(name, projectDir, identifier);
                        Process.Start(projectDir);
                    }
                    close();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 创建项目
        /// </summary>
        /// <param name="dir">目录</param>
        private void createProject(String projectName, String dir, String identifier)
        {
            ArrayList <String> dirs = new ArrayList <String>();

            FCFile.getDirectories(dir, dirs);
            int dirsSize = dirs.Count;

            for (int i = 0; i < dirsSize; i++)
            {
                createProject(projectName, dirs.get(i), identifier);
            }
            ArrayList <String> files = new ArrayList <String>();

            FCFile.getFiles(dir, files);
            int filesSize = files.Count;

            for (int i = 0; i < filesSize; i++)
            {
                String file    = files.get(i);
                String content = "";
                if (file.Substring(file.LastIndexOf('\\')).IndexOf(identifier) != -1)
                {
                    FCFile.read(file, ref content);
                    String newFile = file.Replace(identifier, projectName);
                    FCFile.write(newFile, content);
                    FCFile.removeFile(file);
                    file = newFile;
                }
                FCFile.read(file, ref content);
                if (content.IndexOf(identifier) != -1)
                {
                    content = content.Replace(identifier, projectName);
                    FCFile.write(file, content);
                }
            }
            dirs.Clear();
            files.Clear();
        }
コード例 #3
0
        /**
         * 输出日志
         */
        public override void log(int logType, String message)
        {
            if (checkOut(logType))
            {
                String type = null;
                if (logType == 1)
                {
                    type = "Debug";
                }
                else if (logType == 2)
                {
                    type = "Info";
                }
                else if (logType == 3)
                {
                    type = "Warn";
                }
                else if (logType == 4)
                {
                    type = "Error";
                }
                else if (logType == 5)
                {
                    type = "Fatal";
                }
                //yyyyMMdd
                String dateTime = getNowDate(m_fileAppenderConfig.m_datePattern);
                message = String.Format("{0} {1} {2}\r\n", dateTime, type,
                                        message);

                String logFile = m_fileAppenderConfig.m_logFile;
                if (logFile.Length == 0)
                {
                    return;
                }
                String separator = LogService.FILESEPARATOR;
                String date      = getNowDate("yyyyMMdd");
                int    np        = logFile.LastIndexOf(date);
                if (np < 0)
                {
                    String logDir = LogService.getAppPath() + "\\log\\" + date;
                    FCFile.createDirectory(logDir);
                    int    pos         = logFile.LastIndexOf(separator);
                    String logFileName = logFile.Substring(pos, logFile.Length - pos + 1);
                    String newLogFile  = logDir + separator + logFileName;
                    m_fileAppenderConfig.m_logFile = newLogFile;
                    logFile = newLogFile;
                }
                if (FCFile.isFileExist(logFile))
                {
                    FileInfo file = new FileInfo(logFile);
                    long     len  = file.Length;
                    if (len >= m_maxFileSize)
                    {
                        String             logDir = LogService.getAppPath() + "\\log\\" + date;
                        ArrayList <String> files  = new ArrayList <String>();
                        FCFile.getFiles(logDir, files);
                        int count = files.size();
                        files.clear();
                        int      pos         = logFile.LastIndexOf(separator);
                        int      pos2        = logFile.LastIndexOf(".");
                        String   logFileName = logFile.Substring(pos, pos2 - 1 - pos + 1);
                        String   newFileName = String.Format("{0}\\{1}.{2}.log", logDir, logFileName, count);
                        FileInfo oldFile     = new FileInfo(logFile);
                        FileInfo newFile     = new FileInfo(newFileName);
                        oldFile.MoveTo(newFile.FullName);
                    }
                }
                FCFile.append(logFile, message);
            }
        }