Example #1
0
        //static internal void ExecuteAutofill(this Autofill autofill,
        //                                 string fullPath, bool uploaded) {
        //  if (autofill.StepDataObject.MediaFormat == "Excel") {
        //    autofill.ExecuteExcelAutofill(fullPath, uploaded);
        //  } else if (autofill.StepDataObject.MediaFormat == "PDF") {
        //    autofill.ExecutePDFAutofill(fullPath, uploaded);
        //  } else {
        //    Assertion.AssertNoReachThisCode($"Unrecognized autofill handler for media format {autofill.StepDataObject.MediaFormat}.");
        //  }
        //}


        //static internal void ExecutePDFAutofill2(this Autofill autofill,
        //                                       string templatePath, string fullPath) {
        //  try {
        //    var defaults = autofill.StepDataObject.DataItem.GetPDFFormFields();

        //    var pdfFields = PdfFieldsReader.GetFields(templatePath);

        //    foreach (var field in pdfFields) {
        //      if (defaults.Contains(field.Key)) {
        //        field.Value = defaults.Get<string>(field.Key);
        //      }
        //    }

        //    Stream stream = File.OpenRead(templatePath);

        //    var autofilled = PdfFieldsWriter.WriteFields(stream, pdfFields);

        //    byte[] bytes = autofilled.ToArray();

        //    stream.Close();

        //    using (FileStream fs = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.Write)) {
        //      fs.Write(bytes, 0, (int) bytes.Length);
        //    }

        //  } catch (Exception e) {
        //    throw e;
        //  }
        //}

        #endregion Public methods


        #region Private methods

        static private void ExecuteExcelAutofill(this Autofill autofill, string fullPath, bool uploaded)
        {
            if (uploaded)
            {
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Reporte.Semestral.SASISOPA.Excel")
            {
                autofill.FillOutSasisopa(fullPath);
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Reporte.Mensual.Actividades.CNH.Excel")
            {
                autofill.FillOutMensualActividadesCNH(fullPath);
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Reporte.Mensual.Costos.CNH.Excel")
            {
                autofill.FillOutCostosCNH(fullPath);
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Reporte.Bitacora.Operaciones.Excel")
            {
                autofill.FillOutBitacoraOperaciones(fullPath);
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Reporte.Muestras.Fluidos.Excel")
            {
                autofill.FillOutMuestraFluidos(fullPath);
                return;
            }

            if (autofill.StepDataObject.DataItem.Label == "Extraer.Datos.Archivo.SIPAC")
            {
                autofill.GetDataArchivoSIPAC(fullPath);
                return;
            }
        }