Beispiel #1
0
        public string CreateNewRendiconto(string template, string dir, string filename)
        {
            //creo il file sul desktop
            string path;

            if (string.IsNullOrEmpty(dir))
            {
                path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            }
            else
            {
                path = dir;
            }

            string file = filename;

            //verifico che il file non esista
            string location = Path.Combine(path, file);



            Rendiconto r = RendicontoFactory.CreateRendiconto(template);



            _mapper.SaveRendiconto(r, location);


            return(location);
        }
Beispiel #2
0
        public string CreateNewRendiconto(string template, string dir)
        {
            //creo il file sul desktop
            string path;

            if (string.IsNullOrEmpty(dir))
            {
                path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            }
            else
            {
                path = dir;
            }

            string file = "rendiconto.xml";

            //verifico che il file non esista
            string location = Path.Combine(path, file);

            int i = 1;

            while (File.Exists(location))
            {
                string newName = i.ToString() + "_" + file;
                location = Path.Combine(path, newName);
                i++;
            }



            Rendiconto r = RendicontoFactory.CreateRendiconto(template);



            _mapper.SaveRendiconto(r, location);


            return(location);
        }
Beispiel #3
0
        public string CreateNewRendiconto(RendicontoHeaderDTO header)
        {
            //per prima cosa verifico la validità del percorso di directory fornito
            string path = header.FolderPath;

            if (!Directory.Exists(path))
            {
                throw new ArgumentException("Il percorso specificato per il salvataggio non esiste!");
            }


            //verifico l'estensione del file
            if (!header.FileName.Contains("."))
            {
                header.FileName += ".xml";
            }


            //verifico che il file non esista
            path = Path.Combine(path, header.FileName);

            if (File.Exists(path))
            {
                throw new ArgumentException("Esiste già un file denominato: " + path + "!");
            }

            //A questo punto posso creare il bilancio e salvarlo
            bool isProvinciale = !header.IsRegionale;

            Rendiconto r = RendicontoFactory.CreateRendiconto(isProvinciale, header.Provincia, header.Anno, header.Regione);

            r.Proprietario = header.Proprietario;
            r.SendableTag  = header.SenderTag;
            _mapper.SaveRendiconto(r, path);


            return(path);
        }