//Salvar o arquivo para o plugin FROALA EDITOR
        private object uploadArquivoFroala(HttpPostedFileBase OFile)
        {
            if (!UploadFileValidation.isAllowedExtension(OFile))
            {
                return(new JsonMessage {
                    error = true, message = "A extensão do arquivo não é válida."
                });
            }

            int idOrganizacao = User.idOrganizacao();

            string pathUpload   = Path.Combine(UtilConfig.pathAbsUpload(idOrganizacao), "froala");
            string extensao     = UploadFileValidation.getExtension(OFile);
            string fileName     = String.Concat(UtilString.onlyNumber(DateTime.Now.ToString()), Guid.NewGuid(), extensao);
            string fullPathFile = Path.Combine(pathUpload, fileName);

            if (!Directory.Exists(pathUpload))
            {
                UtilIO.createFolder(pathUpload);
            }

            OFile.SaveAs(fullPathFile);

            string linkArquivo = String.Concat(UtilConfig.linkAbsSistemaUpload(idOrganizacao), "froala/", fileName);

            return(new { link = linkArquivo });
        }
Пример #2
0
        public static bool gerarPDF(string htmlContent, string filename)
        {
            string pathPDF = filename;

            var htmlToPdf = new HtmlToPdfConverter();
            var margins   = new PageMargins();

            margins.Bottom    = 10;          // margins.Left = 5;margins.Right = 5;
            margins.Top       = 10;
            htmlToPdf.Margins = margins;
            htmlToPdf.CustomWkHtmlPageArgs = "--enable-smart-shrinking  --encoding <encoding>";
            htmlToPdf.PageFooterHtml       = "";
            //htmlToPdf.Orientation = NReco.PdfGenerator.PageOrientation.Portrait;
            htmlToPdf.Zoom = 1.0f;

            var conteudo = htmlToPdf.GeneratePdf(htmlContent, null);

            UtilIO.saveBytesToFile(pathPDF, conteudo, FileMode.Create);

            if (File.Exists(pathPDF))
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        //Gerar um registro na tabela no banco de dados
        //Gravar o arquivo em disco
        public string salvar(ArquivoUpload OArquivo, HttpPostedFileBase FileUpload, string pathUpload = "")
        {
            string pathArquivo = "";

            if (FileUpload == null || FileUpload.ContentLength == 0)
            {
                return(pathArquivo);
            }

            OArquivo.extensao = UtilIO.getExtension(FileUpload.FileName);

            OArquivo.contentType = FileUpload.ContentType;

            OArquivo.setDefaultInsertValues();

            db.ArquivoUpload.Add(OArquivo);

            db.SaveChanges();

            if (OArquivo.id > 0)
            {
                this.upload(ref OArquivo, FileUpload, pathUpload, null);

                pathArquivo = OArquivo.path;
            }

            return(pathArquivo);
        }
Пример #4
0
    private static void ZipRes()
    {
        if (_verRes <= 1)
        {
            return;
        }

        string pathPlatVerLast = VerPath(_verRes - 1);
        string zipPath         = Config.WwwRootPath + "res/" + _platform + "/";
        string zipFile         = zipPath + _verRes + ".zip";

        List <string> listResInfoDiff = GetFileInfoDiff(_pathPlatVer + "resourcesinfo", pathPlatVerLast + "resourcesinfo");

        Dictionary <string, string> dictZipFile = new Dictionary <string, string>();

        dictZipFile.Add(_pathPlatVer + "v" + _verRes, "AssetBundle");
        foreach (string diffFile in listResInfoDiff)
        {
            string diffFile2 = _pathPlatVer + diffFile;
            dictZipFile.Add(diffFile2, diffFile);
        }

        UtilIO.CreateDir(zipPath);
        UtilZip.Zip(dictZipFile, zipFile);
    }
Пример #5
0
        public static void saveLog(string strLog, string subFolder = "", string customFileName = "")
        {
            var txt = new StringBuilder();

            txt.AppendLine("***********************************");
            txt.AppendLine("DATETIME: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
            txt.AppendLine("LOG: " + strLog);
            txt.AppendLine("***********************************");

            subFolder = string.IsNullOrEmpty(subFolder) ? "" : $"/{subFolder}";

            var fileName = $"{customFileName}{DateTime.Now.ToShortDateString().onlyNumber()}.log";
            var pathFile = Path.Combine(UtilConfig.pathLogFiles, subFolder);
            var fullName = Path.Combine(pathFile, fileName);

            if (!File.Exists(fullName))
            {
                UtilIO.createFile(pathFile, fileName, false);
            }

            TextWriter Writer = File.AppendText(fullName);

            Writer.Write(txt.ToString());
            Writer.Close();
        }
Пример #6
0
        public static void LoadItem(int index)
        {
            _ScripterForm.CreateNewDocument(Scripter.DEF_FILE_NAME);

            string filename = "Template" + index + ".tem";
            string path     = Path.Combine(Path.Combine(Path.Combine(Scripter.AppPath, "data"), "templates"), filename);

            if (!File.Exists(path))
            {
                UtilSys.MessageBox("File '" + path + "' does not exist.");
                return;
            }

            string[] buffer = UtilIO.ReadFile2Array(path);

            _ScripterForm.CurrentEditor.Loading = true;

            foreach (string line in buffer)
            {
                _ScripterForm.CurrentEditor.AddLine(line);
            }
            _ScripterForm.CurrentEditor.Loading = false;
            _ScripterForm.CurrentEditor.Dirty   = false;
            _ScripterForm.CurrentEditor.InitUndoStack();
            Scripter.DoEvents();
            _ScripterForm.OnReParse();
            Scripter.DoEvents();
            _ScripterForm.CurrentEditor.Focus();
        }
Пример #7
0
        //Gerar um registro na tabela no banco de dados
        //Gravar o arquivo em disco
        public virtual bool salvar(ArquivoUpload OArquivo, HttpPostedFileBase FileUpload = null, string pathUpload = "", List <ThumbDTO> listaThumb = null)
        {
            if (OArquivo.id > 0)
            {
                return(this.atualizar(OArquivo));
            }

            if (OArquivo.id == 0 && FileUpload == null)
            {
                return(false);
            }

            OArquivo.categoria = this.tipoCategoria;

            var flagSucesso = this.inserir(OArquivo);

            if (flagSucesso && FileUpload != null)
            {
                OArquivo.extensao = UtilIO.getExtension(FileUpload.FileName);

                OArquivo.contentType = FileUpload.ContentType;

                this.upload(ref OArquivo, FileUpload, pathUpload, listaThumb);
            }

            return(flagSucesso);
        }
Пример #8
0
        public ArquivoFile Upload(ArquivoFile arquivoFile)
        {
            try
            {
                Guid idFile = Guid.NewGuid();
                if (arquivoFile.ConteudoFileBase64 == null || arquivoFile.ConteudoFileBase64.Length == 0)
                {
                    throw new Exception("Conteúdo vazio do Arquivo (Base64)");
                }

                byte[] conteudo = Convert.FromBase64String(arquivoFile.ConteudoFileBase64);

                UtilIO.CriarPasta(pathArquivos);
                UtilIO.GravaArquivoFileSystem(conteudo, pathArquivos + arquivoFile.NomeFile);

                arquivoFile.IdFile             = idFile.ToString();
                arquivoFile.ConteudoFileBase64 = null;

                List <ArquivoFile> listaArquivos = UtilBase.RecuperarBase().ListaArquivos;
                listaArquivos.Add(arquivoFile);
                this.GravaBaseArquivo(listaArquivos);

                return(arquivoFile);
            } catch (Exception ex)
            {
                throw new Exception("Erro ao gravar o arquivo", ex);
            }
        }
Пример #9
0
        //Método Genérico para salvar logotipos
        public bool salvarLogotipo(int idReferencia, string entidade, HttpPostedFileBase Logotipo, List <ThumbDTO> listaThumb = null)
        {
            var OArquivo = new ArquivoUpload();

            OArquivo.categoria = ArquivoUploadTypes.LOGOTIPO;

            OArquivo.entidade = entidade;

            OArquivo.idReferenciaEntidade = idReferencia;

            OArquivo.extensao = UtilIO.getExtension(Logotipo.FileName);

            OArquivo.contentType = Logotipo.ContentType;

            OArquivo.dtExclusao = DateTime.Now;

            OArquivo.ativo = "S";

            OArquivo.setDefaultInsertValues();

            db.ArquivoUpload.Add(OArquivo);

            db.SaveChanges();

            bool flagUpload = this.upload(ref OArquivo, Logotipo, "", listaThumb);

            return(flagUpload);
        }
Пример #10
0
        //Método Genérico para salvar Audio
        public bool salvarAudio(int idReferencia, string entidade, string descricao, HttpPostedFileBase Audio)
        {
            var OArquivo = new ArquivoUpload();

            OArquivo.categoria = ArquivoUploadTypes.AUDIO;

            OArquivo.entidade = entidade;

            OArquivo.titulo = descricao;

            OArquivo.legenda = descricao;

            OArquivo.idReferenciaEntidade = idReferencia;

            OArquivo.extensao = UtilIO.getExtension(Audio.FileName);

            OArquivo.contentType = Audio.ContentType;

            OArquivo.dtExclusao = DateTime.Now;

            OArquivo.ativo = "S";

            OArquivo.setDefaultInsertValues();

            db.ArquivoUpload.Add(OArquivo);

            db.SaveChanges();

            bool flagUpload = this.upload(ref OArquivo, Audio);

            return(flagUpload);
        }
Пример #11
0
    private static void UpdateAssetBundles()
    {
        _pathPlatVer = VerPath(_verRes);
        UtilIO.CreateDir(Config.WwwRootPath);

        ZipRes();
        WriteVerInfo();
    }
Пример #12
0
        public ArquivoFile Download(string idFile)
        {
            ArquivoFile arquivoFile = UtilBase.RecuperarBase().ListaArquivos.FirstOrDefault(x => x.IdFile == idFile);

            byte[] arq = UtilIO.RecuperaArquivoFileSystem(pathArquivos + arquivoFile.NomeFile);
            arquivoFile.ConteudoFile = arq;
            return(arquivoFile);
        }
Пример #13
0
        public object Delete(string idFile)
        {
            ArquivoFile        arquivoFile   = UtilBase.RecuperarBase().ListaArquivos.FirstOrDefault(x => x.IdFile == idFile);
            List <ArquivoFile> listaArquivos = this.ListarArquivos().ToList();

            listaArquivos = listaArquivos.Where(x => x.IdFile != idFile).ToList();
            this.GravaBaseArquivo(listaArquivos);
            UtilIO.DeleteArquivoFileSystem(pathArquivos + arquivoFile.NomeFile);
            return(arquivoFile);
        }
Пример #14
0
        public static bool Load(string path)
        {
            Debug.Assert(null != path);
            Debug.Assert(string.Empty != path);

            if (!File.Exists(path))
            {
                UtilSys.MessageBoxInfo("Settings Load: " + path);
                CreateDefaultSettingsFile(path);

                UtilSys.Sleep(1000);

                return(false);
            }

            _path = path;

            _dic.Clear();

            List <string> lst = UtilIO.ReadFile(_path);

            char[]   sep = { ' ', '=', ' ' };
            string[] stringSeparators = new string[] { " = " };

            foreach (string line in lst)
            {
                string[] tmp = line.Split(stringSeparators, StringSplitOptions.None);
                _dic.Add(tmp[0], tmp[1]);
            }

            // at this point we have settings loaded
            // but there is a possibility that new setting keys are not in file, we have to check and fix that
            string key   = string.Empty;
            string value = string.Empty;

            foreach (string keyLine in m_Settings)
            {
                string[] tmp = keyLine.Split(stringSeparators, StringSplitOptions.None);

                key   = tmp[0];
                value = tmp[1];

                if (!_dic.ContainsKey(key))
                {
                    Add(key, value);
                }
            }

            Save();

            return(true);
        }
Пример #15
0
    private static void BuildAssetBundles(BuildTarget buildTarget)
    {
        _pathPlatVer = VerPath(_verRes);
        UtilIO.CreateDir(_pathPlatVer);

        CopyLua();
        AssetDatabase.Refresh();
        ClearAssetBundleNames();
        SetAssetBundleName();
        AssetBundleManifest mainfest = BuildPipeline.BuildAssetBundles(_pathPlatVer, BuildAssetBundleOptions.UncompressedAssetBundle, buildTarget);

        BuildAssetBundleAfter(mainfest);
    }
Пример #16
0
        public static List <string> LoadServerIPHistory()
        {
            if (!File.Exists(_pathServerIPHistory))
            {
                using (StreamWriter SW = File.CreateText(_pathServerIPHistory))
                {
                }
            }

            List <string> history = UtilIO.ReadFile(_pathServerIPHistory);

            return(history);
        }
Пример #17
0
    /// <summary>
    /// 解压文件
    /// </summary>
    /// <param name="zipFile">压缩文件</param>
    /// <param name="outPath">解压目录</param>
    public static void UnZip(string sourceFile, string targetPath)
    {
        if (!File.Exists(sourceFile))
        {
            Debug.LogError("sourceFile: " + sourceFile + " not exist");
            return;
        }
        UtilIO.CreateDir(targetPath);

        using (var s = new ZipInputStream(File.OpenRead(sourceFile)))
        {
            ZipEntry theEntry;
            while ((theEntry = s.GetNextEntry()) != null)
            {
                if (theEntry.IsDirectory)
                {
                    continue;
                }

                string directorName = Path.Combine(targetPath, Path.GetDirectoryName(theEntry.Name));
                string fileName     = Path.Combine(directorName, Path.GetFileName(theEntry.Name));

                UtilIO.CreateDir(directorName);

                if (!String.IsNullOrEmpty(fileName))
                {
                    using (FileStream streamWriter = File.Create(fileName))
                    {
                        int    size = 4096;
                        byte[] data = new byte[size];
                        while (true)
                        {
                            size = s.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                streamWriter.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
Пример #18
0
        public static bool Parse(FrmScripter frmScp, Editor editor)
        {
            Debug.Assert(null != frmScp);
            Debug.Assert(null != editor);

            _frm    = frmScp;
            _editor = editor;

            _editor.Variables.Clear();
            _editor.Functions.Clear();

            CreateDefaultTreeNodes();
            CreateTreeNodes(_frm.tvwImported, _editor.Path2File);

            List <string> lst = new List <string>(_editor.Lines);

            ParseLines(lst);

            foreach (string rawline in editor.Lines)
            {
                string line = rawline.Trim();

                if (line.StartsWith(keyword_import))
                {
                    string str = line.Replace(keyword_import, "");
                    str = str.Trim();
                    str = str.Substring(1, str.Length - 2);

                    CreateTreeNodes(frmScp.tvwImported, str);

                    lst = UtilIO.ReadFile(Path.Combine(Application.StartupPath, str));

                    ParseLines(lst);
                }
            }

            foreach (TreeNode node in _nodesFiles)
            {
                node.Expand();
            }

            _frm.tvwImported.SelectedNode = _frm.tvwImported.Nodes[0];

            return(true);
        }
Пример #19
0
        // here we simply import other script file into our _lines List at the current position
        private static void LoadImportScript(string path2Import)
        {
            Debug.Assert(null != path2Import);

            _vm.host.WriteLog("Loading Import Script: " + path2Import);

            string tmp = path2Import.Trim();

            string path = Path.Combine(_vm.host.StartupPath, tmp);

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("File '" + path + "' does not exist.");
            }

            try
            {
                List <string> lines = UtilIO.ReadFile(path);

                if (_bWriteLog)
                {
                    _vm.host.WriteLog("Loading Import Script: '" + path + "', Lines: " + lines.Count);
                }

                _LoadedFiles.Push(path);
                _LineNumbers.Push(_lineNum);
                _lineNum = -1;

                int index = _lines.IndexOf(_raw);
                _lines.RemoveAt(index);

                _lines.Insert(index, _ImportEndMark + "[" + path + "]");

                for (int i = lines.Count - 1; i > -1; --i)
                {
                    _lines.Insert(index, lines[i]);
                }
                _lines.Insert(index, _ImportBeginMark + "[" + path + "]");
            }
            catch
            {
                throw;
            }
        }
Пример #20
0
        public static string[] Load(FrmScripter frmScp, MRU mru, string path)
        {
            if (!File.Exists(path))
            {
                UtilSys.MessageBox("File '" + path + "' does not exist.");
                mru.Remove(path);
                mru.Save();
                return(null);
            }

            frmScp.Output("Loading file: " + path);

            string[] buffer = UtilIO.ReadFile2Array(path);

            mru.Add(path);
            mru.Save();

            return(buffer);
        }
Пример #21
0
        public static void Load(string path)
        {
            List <string> lst = UtilIO.ReadFile(path);

            items.Clear();
            comments.Clear();

            if (0 == lst.Count)
            {
                return;
            }

            if ("v1.1" == lst[0])
            {
                ParseScopedDataFile(lst);
                return;
            }

            ParseVariables(lst);
        }
Пример #22
0
        //Método Genérico para salvar Documentos
        public bool salvarDocumento(int idReferencia, string entidade, string descricao, HttpPostedFileBase Documento, int idOrganizacaoParam, int idusuarioCadastroParam = 0)
        {
            if (idOrganizacaoParam == 0)
            {
                idOrganizacaoParam = User.idOrganizacao();
            }

            var OArquivo = new ArquivoUpload();

            OArquivo.categoria = ArquivoUploadTypes.DOCUMENTO;

            OArquivo.entidade = entidade;

            OArquivo.titulo = descricao;

            OArquivo.legenda = descricao;

            OArquivo.idReferenciaEntidade = idReferencia;

            OArquivo.extensao = UtilIO.getExtension(Documento.FileName);

            OArquivo.contentType = Documento.ContentType;

            OArquivo.ativo = "S";

            OArquivo.idOrganizacao = idOrganizacaoParam;

            OArquivo.idUsuarioCadastro = idusuarioCadastroParam;

            OArquivo.dtCadastro = DateTime.Now;;

            db.ArquivoUpload.Add(OArquivo);

            db.SaveChanges();

            bool flagUpload = this.upload(ref OArquivo, Documento);

            return(flagUpload);
        }
Пример #23
0
        public static void Load(string path, Script script)
        {
            Debug.Assert(null != path);
            Debug.Assert(null != script);

            _script = script;
            _tokens = new List <string>();

            if (_bWriteLog)
            {
                _vm.host.WriteLog("\r\n<Parser>");
            }

            try
            {
                _lines = UtilIO.ReadFile(path);

                if (_bWriteLog)
                {
                    _vm.host.WriteLog("Parser Load File: '" + path + "', Lines: " + _lines.Count);
                }

                _LoadedFiles.Push(path);
                _LineNumbers.Push(0);

                ProcessLines();
            }
            catch
            {
                throw;
            }

            if (_bWriteLog)
            {
                DumpFinalScriptToLogFile();
                _vm.host.WriteLog("</Parser>");
            }
        }
        public string exportar(List <string> listaUrlArquivosAssociados)
        {
            string baseName            = String.Concat("ARQUIVOS_", User.id(), "_", UtilString.onlyNumber(DateTime.Now.ToString()));
            string nomePathTempArquivo = String.Concat(UtilConfig.pathAbsTempFiles, "/", baseName);

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

            foreach (var urlArquivoAssociado in listaUrlArquivosAssociados)
            {
                string basePath = User.idOrganizacao() > 0 ? UtilConfig.pathAbsUpload(idOrganizacao) : $"{UtilConfig.pathAbsUploadFiles}upload/";

                string pathArquivoAssociado = String.Concat(basePath, urlArquivoAssociado);

                string pathFile = Path.Combine(UtilConfig.pathAbsRaiz, pathArquivoAssociado);

                if (!File.Exists(pathFile))
                {
                    continue;
                }

                var OFileInfo = new FileInfo(pathFile);
                UtilIO.copiarArquivo(OFileInfo, nomePathTempArquivo, OFileInfo.Name);
            }

            string nomeArquivoZip     = String.Concat(baseName, ".zip");
            string nomeFullArquivoZip = string.Concat(UtilConfig.pathAbsTempFiles, "/", nomeArquivoZip);

            ZipFile.CreateFromDirectory(nomePathTempArquivo, nomeFullArquivoZip, CompressionLevel.Optimal, true);

            var DirectoryInfo = new DirectoryInfo(nomePathTempArquivo);

            DirectoryInfo.Delete(true);

            return(nomeArquivoZip);
        }
        //
        private void salvarImagem(HttpPostedFileBase OArquivo, string nomeImagem, int idOrganizacaoInfo = 0)
        {
            if (User.idOrganizacao() > 0)
            {
                idOrganizacaoInfo = User.idOrganizacao();
            }

            string pathFolder = Path.Combine(UtilConfig.pathAbsUpload(idOrganizacaoInfo), "logotipo");

            string pathImagem = Path.Combine(pathFolder, nomeImagem);

            if (File.Exists(pathImagem))
            {
                File.Delete(pathImagem);
            }

            if (!Directory.Exists(pathFolder))
            {
                UtilIO.createFolder(pathFolder);
            }

            OArquivo.SaveAs(pathImagem);
        }
Пример #26
0
        public string gerarZip(List <ReceitaDespesaArquivoVW> listaArquivos)
        {
            if (!listaArquivos.Any())
            {
                return("");
            }

            string baseName             = String.Concat("Arquivos_Financeiros_", User.id(), "_", UtilString.onlyNumber(DateTime.Now.ToString()));
            string nomePathTempArquivos = String.Concat(UtilConfig.pathAbsTempFiles, "/", baseName);

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

            foreach (var OArquivo in listaArquivos)
            {
                string pathFile = Path.Combine(UtilConfig.pathAbsUpload(OArquivo.idOrganizacao.toInt()), OArquivo.path);

                var OFileInfo = new FileInfo(pathFile);

                if (!OFileInfo.Exists)
                {
                    continue;
                }

                UtilIO.copiarArquivo(OFileInfo, nomePathTempArquivos, OFileInfo.Name);
            }

            string nomeArquivoZip = String.Concat(baseName, ".zip");

            string nomeFullArquivoZip = string.Concat(UtilConfig.pathAbsTempFiles, "/", nomeArquivoZip);

            ZipFile.CreateFromDirectory(nomePathTempArquivos, nomeFullArquivoZip, CompressionLevel.Optimal, true);

            return(nomeArquivoZip);
        }
Пример #27
0
        //Salvar o arquivo em disco e configurar os caminhos para buscar posteriormente
        public bool upload(ref ArquivoUpload OArquivo, HttpPostedFileBase FileUpload, string pathUpload = "", List <ThumbDTO> listaThumb = null)
        {
            string pathBaseAbs = String.IsNullOrEmpty(pathUpload) ? UtilConfig.pathAbsUpload(OArquivo.idOrganizacao.toInt()) : pathUpload;

            string pathPasta = String.Concat(OArquivo.entidade, "/", OArquivo.categoria, "/", OArquivo.idReferenciaEntidade, "/");

            string pathPastaThumb = String.Concat(pathPasta, "thumb/");

            string nomeArquivo = FileUpload.FileName ?? String.Concat(OArquivo.id.ToString(), OArquivo.extensao);

            OArquivo.path        = String.Concat(pathPasta, nomeArquivo);
            OArquivo.pathThumb   = pathPastaThumb;
            OArquivo.nomeArquivo = nomeArquivo;

            //Criar os diretórios necessários.
            UtilIO.createFolder(Path.Combine(pathBaseAbs, pathPasta));
            UtilIO.createFolder(Path.Combine(pathBaseAbs, pathPastaThumb));

            //Salvar o arquivo principal
            FileUpload.SaveAs(String.Concat(pathBaseAbs, OArquivo.path));

            //Caso seja uma imagem, fazer o redimensionamento para o tamanho padrão do sistema.
            if (UploadConfig.validarImagem(FileUpload))
            {
                Instructions InstructionsImage = new Instructions {
                    Format = OArquivo.extensao.Replace(".", ""), Mode = FitMode.Max
                };

                //Tamanho padrão para apresentação no grid do sistema
                InstructionsImage.Height = 100;

                string diretorioThumbSistema        = String.Concat(pathPastaThumb, "sistema");
                string diretorioArquivoThumbSistema = String.Concat(diretorioThumbSistema, "/", nomeArquivo);

                UtilIO.createFolder(Path.Combine(pathBaseAbs, diretorioThumbSistema));

                FileUpload.InputStream.Seek(0, SeekOrigin.Begin);
                ImageBuilder.Current.Build(new ImageJob(FileUpload, Path.Combine(pathBaseAbs, diretorioArquivoThumbSistema), InstructionsImage));

                if (listaThumb == null || listaThumb.Count == 0)
                {
                    listaThumb = new List <ThumbDTO>();
                    listaThumb.Add(new ThumbDTO {
                        folderName = "sistema", height = 50, width = 0
                    });
                }

                foreach (var Item in listaThumb)
                {
                    InstructionsImage.Width  = Item.width;
                    InstructionsImage.Height = Item.height;

                    string diretorioThumb        = String.Concat(pathPastaThumb, Item.folderName);
                    string diretorioArquivoThumb = String.Concat(diretorioThumb, "/", nomeArquivo);

                    UtilIO.createFolder(Path.Combine(pathBaseAbs, diretorioThumb));

                    ImageBuilder.Current.Build(new ImageJob(FileUpload, Path.Combine(pathBaseAbs, diretorioArquivoThumb), InstructionsImage));
                }
            }

            if (!File.Exists(String.Concat(pathBaseAbs, OArquivo.path)))
            {
                int idArquivo = OArquivo.id;

                this.db.ArquivoUpload.Where(x => x.id == idArquivo).Delete();

                return(false);
            }

            this.db.SaveChanges();

            return(true);
        }
Пример #28
0
        private static void ProcessLines()
        {
            string line         = string.Empty;
            bool   blockComment = false;

            _lineNum = -1;

            for (int i = 0; i < _lines.Count; ++i)
            {
                ++_lineNum;

                _raw = _lines[i];
                line = _lines[i].Trim();

                if (!blockComment)
                {
                    line = InlineBlockComment(line);
                }

                if (blockComment && line.StartsWith(@"*/"))
                {
                    blockComment = false;
                    continue;
                }

                if (blockComment)
                {
                    continue;
                }

                if (!blockComment && line.StartsWith(@"/*"))
                {
                    blockComment = true;
                    continue;
                }

                if (line.Contains(_ImportEndMark))
                {
                    _script.GoBackToGlobalScope();
                    _LoadedFiles.Pop();
                    _lineNum = _LineNumbers.Pop();
                }

                if (UtilIO.SkipLine(line))
                {
                    if (_bWriteLog)
                    {
                        _vm.host.WriteLog("Skipped\t" + line);
                    }

                    continue;
                }

                if (_bWriteLog)
                {
                    _vm.host.WriteLog("Parsing\t" + line);
                }

                List <string> rawTokens = Tokenizer.Init(line);

                SeparateComment(rawTokens);
                _tokens = Compatibility.CreateTokens(_tokens); // compatibility layer

                ProcessTokens(_lineNum);
            }
        }
Пример #29
0
        private static void ParseVariables(List <string> lst)
        {
            string key     = string.Empty;
            string value   = string.Empty;
            string comment = string.Empty;

            foreach (string line in lst)
            {
                string str = line.Trim();

                //_vm.host.WriteLog(str);

                if (UtilIO.SkipLine(str))
                {
                    //_vm.host.WriteLog("Line '" + str + "' skipped.");
                }
                else
                {
                    //_vm.host.WriteLog("Parsing line: '" + str + "'");

                    // look 4 comment
                    int index = line.LastIndexOf(@"//");

                    string[] result = new string[2];

                    if (-1 == index) // no comment
                    {
                        result[0] = line;
                        result[1] = "";
                    }
                    else
                    {
                        result[0] = line.Substring(0, index);
                        result[1] = line.Substring(index, line.Length - index);
                    }

                    if (2 == result.Length)
                    {
                        comment = result[1].Trim();
                    }
                    else
                    {
                        comment = "";
                    }

                    key   = ParseKey(result[0]);
                    value = string.Empty;

                    string tmp = result[0].Replace(key, "");

                    bool write = false;
                    for (int i = 0; i < tmp.Length; ++i)
                    {
                        if (write)
                        {
                            value += tmp[i];
                        }
                        else
                        {
                            if (tmp[i] == '=')
                            {
                                write = true;
                            }
                        }
                    }

                    value = value.Trim();
                    value = value.Substring(1, value.Length - 2);

                    items.Add(key, value);
                    comments.Add(comment);
                }
            }
        }
Пример #30
0
 private static void CopyLua()
 {
     UtilIO.CopyDir(Config.LuaPath, Config.LuaPathRes, ".txt");
 }