예제 #1
0
        private static int RunSendAndReturnExitCode(SendLDocOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.InputFile))
            {
                return(3); // this shouldn't happen anyway, because parameter is already required
            }
            var fi = new FileInfo(options.InputFile);

            if (!fi.Exists)
            {
                log.Error(string.Format("ERROR: file {0} doesn't exist.", fi.Name));
                return(4);
            }
            var tokenClient = GetAuthClient(options.FindCertificateByValue, options.IsDevelopment);

            if (tokenClient == null)
            {
                return(6);
            }

            log.Info($"SendLDoc Method...\nWith file: {options.InputFile}");
            Guid guidTransaction = Guid.Empty;

            try
            {
                guidTransaction = SendDocument(tokenClient, options.IsDevelopment, fi, options.Naziv, options.Koda, options.NazivDobavitelja, options.SifraDobavitelja,
                                               options.DavcnaStevilkaDobavitelja, options.StevilkaRacuna, options.DatumIzdajeRacuna,
                                               options.Leto, options.Node);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(100);
            }
            log.Info("Transaction GUID: " + guidTransaction);
            return(0);
        }
예제 #2
0
        private static int RunSendAndReturnExitCode(SendLDocOptions options)
        {
            if (options.InputFiles.Count() < 1)
            {
                return 3; // this shouldn't happen anyway, because parameter is already required
            }
            var  files = new List<FileInfo>();
            foreach (var f in options.InputFiles)
            {
                var fi = new FileInfo(f);
                if (!fi.Exists)
                {
                    log.Error(string.Format("ERROR: file {0} doesn't exist.", fi.Name));
                    return 4;
                }
                files.Add(fi);
            }

            log.Info(string.Format("SendLDoc Method...\nWith files: {0}", string.Join("; ", options.InputFiles.ToArray())));

            Guid guidTransaction = Guid.Empty;
            try
            {
                guidTransaction = SendLogicaDocument(files, options.Naziv, options.Koda, options.NazivDobavitelja, options.SifraDobavitelja,
                                        options.DavcnaStevilkaDobavitelja, options.StevilkaRacuna, options.DatumIzdajeRacuna,
                                        options.Leto, options.Node, options.Debug);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return 100;
            }
            log.Info("Transaction GUID: " + guidTransaction);
            return 0;
        }