text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Web.Mvc;
using bv.model.Model.Core;
using eidss.model.Reports;
using eidss.model.Reports.AZ;
using eidss.model.Reports.Common;
using eidss.model.Reports.GG;
using eidss.model.Reports.KZ;
using eidss.model.Resources;
using eidss.webclient.Models.Reports;
using eidss.webclient.Utils;

namespace eidss.webclient.Controllers
{
    [AuthorizeEIDSS]
    public class ReportController : Controller
    {
        #region Paper Forms

        private string GetFullPathForPaperForm(string reportName)
        {
            var ret = String.Format("/Content/PaperForms/{0}/{1}", ModelUserContext.CurrentLanguage, reportName);
            if (Server != null && !System.IO.File.Exists(Server.MapPath(ret)))
            {
                ret = String.Format("/Content/PaperForms/{0}/{1}", "en", reportName);
            }
            return ret;
        }

        public FileResult AvianDiseaseOutbreaksForm()
        {
            const string reportName = "Investigation Form For Avian Disease Outbreaks.pdf";
            var result = new FilePathResult(GetFullPathForPaperForm(reportName), MediaTypeNames.Application.Octet)
            {
                FileDownloadName = reportName
            };
            return result;
        }

        public FileResult LivestockDiseaseOutbreaksForm()
        {
            const string reportName = "Investigation Form For Livestock Disease Outbreaks.pdf";
            var result = new FilePathResult(GetFullPathForPaperForm(reportName), MediaTypeNames.Application.Octet)
            {
                FileDownloadName = reportName
            };
            return result;
        }

        public FileResult GeneralCaseInvestigationForm()
        {
            const string reportName = "General Case Investigation Form.pdf";
            var result = new FilePathResult(GetFullPathForPaperForm(reportName), MediaTypeNames.Application.Octet)
            {
                FileDownloadName = reportName
            };
            return result;
        }

        #endregion

        #region Print Barcodes

        public ActionResult PrintBarcodes()
        {
            ViewBag.GetReportActionName = "ShowPrintBarcodes";
            ViewBag.Title = EidssMenu.Instance.GetString("MenuUniversalBarcodes");

            return View("Common/PrintBarcodes", new PrintBarcodesModel());
        }

        public ActionResult ShowPrintBarcodes(PrintBarcodesModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportNewBarcodes(model.BarcodeType, model.Quantity);
                resultParameters = new ReportResultParameters(report, "PrintBarcodes",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region Common Human Reports

        public ActionResult HumDiagnosisToChangedDiagnosis()
        {
            ViewBag.GetReportActionName = "ShowHumDiagnosisToChangedDiagnosis";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumDiagnosisToChangedDiagnosis");
            ViewBag.ArrayForRename = new List<string> {"InitialDiagnoses.CheckedItems", "FinalDiagnoses.CheckedItems"};

            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon()) {IsSettlementVisible = true};
            return View("Common/DToChangedD", new DToChangedDModel {Address = address});
        }

        public ActionResult ShowHumDiagnosisToChangedDiagnosis(DToChangedDModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                if (!bv.common.Core.Utils.IsEmpty(model.InitialDiagnosesList))
                {
                    model.InitialDiagnoses.CheckedItems = model.InitialDiagnosesList.Split(new[] {","},
                        StringSplitOptions.RemoveEmptyEntries);
                }

                if (!bv.common.Core.Utils.IsEmpty(model.FinalDiagnosesList))
                {
                    model.FinalDiagnoses.CheckedItems = model.FinalDiagnosesList.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                }
                //модель может содержать выбранные диагнозы, перечисленные через запятую, собранные в один элемент массива
                //CorrectDiagnoses(model.InitialDiagnoses);
                //CorrectDiagnoses(model.FinalDiagnoses);

                byte[] report = wrapper.Client.ExportHumDiagnosisToChangedDiagnosis((DToChangedDSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Concordance_of_Initial_and_Final_Diagnosis",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        private void CorrectDiagnoses(MultipleDiagnosisModel dm)
        {
            if (dm.CheckedItems.Length == 1)
            {
                string item0 = dm.CheckedItems[0];
                if (item0.Contains(","))
                {
                    dm.CheckedItems = item0.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                }
            }
        }

        public ActionResult HumMonthlyMorbidityAndMortality()
        {
            ViewBag.GetReportActionName = "ShowHumMonthlyMorbidityAndMortality";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumMonthlyMorbidityAndMortality");
            return View("Common/BaseDate", new BaseDateModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowHumMonthlyMorbidityAndMortality(BaseDateModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumMonthlyMorbidityAndMortality(model);
                resultParameters = new ReportResultParameters(report, "Human_Monthly_Morbidity_And_Mortality",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region AZ Human Reports

        public JsonResult GetRayons(AddressModel model)
        {
            object jsonData = (model.RegionId.HasValue && model.RegionId.Value > 0)
                ? new SelectList(model.GetRayons(), "Value", "Text")
                : (object) string.Empty;

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetTransportCHERayons(TransportCHEModel model)
        {
            object jsonData = (model.RegionId.HasValue && model.RegionId.Value > 0)
                ? new SelectList(model.GetRayons(), "Value", "Text")
                : (object) string.Empty;

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetRayonsList(AddressMultiselectModel model)
        {
            object jsonData = !bv.common.Core.Utils.IsEmpty(model.RegionsSelected)
                ? new SelectList(model.GetRayons(model.RegionsSelected), "Value", "Text")
                : (object) string.Empty;

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetSettlements(AddressModel model)
        {
            object jsonData = (model.RayonId.HasValue && model.RayonId.Value > 0)
                ? new SelectList(model.GetSettlements(), "Value", "Text")
                : (object) string.Empty;

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public ActionResult HumFormN1A3()
        {
            return HumFormN1(true);
        }

        public ActionResult HumFormN1A4()
        {
            return HumFormN1(false);
        }

        public ActionResult HumFormN1(bool isA3Format)
        {
            ViewBag.GetReportActionName = "ShowHumFormN1";
            ViewBag.Title = EidssMenu.Instance.GetString("HumFormN1");
            var model = new FormNo1Model(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon())
            {
                PageSize = isA3Format
                    ? FilterHelper.PageSizeA3
                    : FilterHelper.PageSizeA4
            };
            return View("AZ/FormNo1", model);
        }

        public ActionResult ShowHumFormN1A3(FormNo1Model model)
        {
            return ShowHumFormN1(model);
        }

        public ActionResult ShowHumFormN1A4(FormNo1Model model)
        {
            return ShowHumFormN1(model);
        }

        public ActionResult ShowHumFormN1(FormNo1Model model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumFormN1((FormNo1SurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Form_No_1",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumDataQualityIndicators()
        {
            ViewBag.GetReportActionName = "ShowDataQualityIndicators";
            ViewBag.Title = EidssMenu.Instance.GetString("HumDataQualityIndicators");
            return View("AZ/DataQualityIndicators",
                new DataQualityIndicatorsModel {CanWorkWithArchive = false, ShowRayonFilter = true, EndMonth = DateTime.Today.Month});
        }

        public ActionResult ShowDataQualityIndicators(DataQualityIndicatorsModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumDataQualityIndicators((DataQualityIndicatorsSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Data_Quality_Indicators",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumDataQualityIndicatorsRayons()
        {
            ViewBag.GetReportActionName = "ShowDataQualityIndicatorsRayons";
            ViewBag.Title = EidssMenu.Instance.GetString("HumDataQualityIndicatorsRayons");
            return View("AZ/DataQualityIndicators",
                new DataQualityIndicatorsModel {CanWorkWithArchive = false, EndMonth = DateTime.Today.Month});
        }

        public ActionResult ShowDataQualityIndicatorsRayons(DataQualityIndicatorsModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                if (!bv.common.Core.Utils.IsEmpty(model.MultipleDiagnosisFilter_CheckedItems))
                {
                    model.MultipleDiagnosisFilter.CheckedItems = model.MultipleDiagnosisFilter_CheckedItems.Split(new[] {","},
                        StringSplitOptions.RemoveEmptyEntries);
                }
                byte[] report = wrapper.Client.ExportHumDataQualityIndicatorsRayons((DataQualityIndicatorsSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Data_Quality_Indicators",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumSummaryByRayonDiagnosisAgeGroups()
        {
            ViewBag.GetReportActionName = "ShowHumSummaryByRayonDiagnosisAgeGroups";
            ViewBag.Title = EidssMenu.Instance.GetString("HumSummaryByRayonDiagnosisAgeGroups");
            ViewBag.MaxCheckedCount = SummaryByRayonDiagnosisModel.HumMaxDiagnosisCount;
            return View("AZ/SummaryByRayonDiagnosis", new SummaryByRayonDiagnosisModel(null) {CanWorkWithArchive = false});
        }

        public ActionResult ShowHumSummaryByRayonDiagnosisAgeGroups(SummaryByRayonDiagnosisModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                if (!bv.common.Core.Utils.IsEmpty(model.MultipleDiagnosisFilter_CheckedItems))
                {
                    model.MultipleDiagnosisFilter.CheckedItems =
                        model.MultipleDiagnosisFilter_CheckedItems.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                }
                byte[] report = wrapper.Client.ExportHumSummaryByRayonDiagnosisAgeGroups(model);
                resultParameters = new ReportResultParameters(report, "Human_Summary_By_Rayon_Diagnosis_Age_Groups",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumComparativeAZReport()
        {
            ViewBag.GetReportActionName = "ShowHumComparativeAZReport";
            ViewBag.Title = EidssMenu.Instance.GetString("HumComparativeReport");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("AZ/Comparative", new ComparativeModel {Address1 = address});
        }

        public ActionResult ShowHumComparativeAZReport(ComparativeModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumComparativeAZReport((ComparativeSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Comparative_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumExternalComparativeReport()
        {
            ViewBag.GetReportActionName = "ShowHumExternalComparativeReport";
            ViewBag.Title = EidssMenu.Instance.GetString("HumExternalComparativeReport");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("AZ/ExternalComparative", new ExternalComparativeModel(address));
        }

        public ActionResult ShowHumExternalComparativeReport(ExternalComparativeModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumExternalComparativeReport((ExternalComparativeSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_External_Comparative_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumMainIndicatorsOfAFPSurveillance()
        {
            ViewBag.GetReportActionName = "ShowHumMainIndicatorsOfAFPSurveillance";
            ViewBag.Title = EidssMenu.Instance.GetString("HumMainIndicatorsOfAFPSurveillance");
            return View("AZ/AFPSurveillance", new AFPModel());
        }

        public ActionResult ShowHumMainIndicatorsOfAFPSurveillance(AFPModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumMainIndicatorsOfAFPSurveillance(model);
                resultParameters = new ReportResultParameters(report, "Human_Main_Indicators_Of_AFP_Surveillance",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumAdditionalIndicatorsOfAFPSurveillance()
        {
            ViewBag.GetReportActionName = "ShowHumAdditionalIndicatorsOfAFPSurveillance";
            ViewBag.Title = EidssMenu.Instance.GetString("HumAdditionalIndicatorsOfAFPSurveillance");
            return View("AZ/AFPSurveillance", new AFPModel());
        }

        public ActionResult ShowHumAdditionalIndicatorsOfAFPSurveillance(AFPModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumAdditionalIndicatorsOfAFPSurveillance(model);
                resultParameters = new ReportResultParameters(report, "Human_Additional_Indicators_Of_AFP_Surveillance",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public JsonResult GetReportingPeriodList(AFPModel model)
        {
            List<SelectListItem> list = model.PeriodList.ConvertToSelectListItem().ToList();
            object jsonData = (list.Count > 0)
                ? new SelectList(list, "Value", "Text")
                : (object) string.Empty;
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetQuartersList(BaseYearQuarterModel model)
        {
            List<SelectListItem> list = model.GetQuarters().ConvertToSelectListItem().ToList();
            object jsonData = (list.Count > 0)
                ? new SelectList(list, "Value", "Text")
                : (object) string.Empty;
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        public ActionResult HumWhoMeaslesRubellaReport()
        {
            ViewBag.GetReportActionName = "ShowHumWhoMeaslesRubellaReport";
            ViewBag.Title = EidssMenu.Instance.GetString("HumWhoMeaslesRubellaReport");
            //return View("Common/BaseDate", new WhoMeaslesRubellaModel());
            return View("AZ/HumWhoMeaslesRubellaReport", new WhoMeaslesRubellaModel());
        }

        public ActionResult ShowHumWhoMeaslesRubellaReport(WhoMeaslesRubellaModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                var report = wrapper.Client.ExportHumWhoMeaslesRubellaReport(model);
                resultParameters = new ReportResultParameters(report, "Human_Measles_Rubella_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumComparativeReportOfTwoYears()
        {
            ViewBag.GetReportActionName = "ShowHumComparativeReportOfTwoYears";
            ViewBag.Title = EidssMenu.Instance.GetString("HumComparativeReportOfTwoYears");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("AZ/ComparativeTwoYears", new ComparativeTwoYearsModel {Address = address});
        }

        public ActionResult ShowHumComparativeReportOfTwoYears(ComparativeTwoYearsModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumComparativeReportOfTwoYears((ComparativeTwoYearsSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Comparative_Report_of_Two_years",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region AZ Vet Reports

        public ActionResult VeterinaryCasesReportAZ()
        {
            ViewBag.GetReportActionName = "ShowVeterinaryCasesReportAZ";
            ViewBag.Title = EidssMenu.Instance.GetString("VeterinaryCasesReport");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            var model = new VetCasesModel
            {
                Address = address,
                StartYear = DateTime.Now.Year,
                StartMonth = DateTime.Now.Month,
                EndYear = DateTime.Now.Year,
                EndMonth = DateTime.Now.Month,
            };
            return View("AZ/VetCase", model);
        }

        public ActionResult ShowVeterinaryCasesReportAZ(VetCasesModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVeterinaryCasesReport((VetCasesSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Cases_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VeterinaryLaboratoriesAZ()
        {
            ViewBag.GetReportActionName = "ShowVeterinaryLaboratoriesAZ";
            ViewBag.Title = EidssMenu.Instance.GetString("VeterinaryLaboratoriesAZ");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            var model = new VetLabModel
            {
                Address = address,
                Year = DateTime.Now.Year,
            };
            return View("AZ/VetLab", model);
        }

        public ActionResult ShowVeterinaryLaboratoriesAZ(VetLabModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVeterinaryLaboratoriesAZReport((VetLabSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Laboratories_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VeterinaryFormVet(string reportBaseId)
        {
            ViewBag.GetReportActionName = string.Format("Show{0}", reportBaseId);
            ViewBag.Title = EidssMenu.Instance.GetString(reportBaseId);
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            var model = new VetCasesModel
            {
                Address = address,
                StartYear = DateTime.Now.Year,
                StartMonth = DateTime.Now.Month,
                EndYear = DateTime.Now.Year,
                EndMonth = DateTime.Now.Month,
            };
            return View("AZ/VetCase", model);
        }

        public ActionResult VeterinaryFormVet1()
        {
            return VeterinaryFormVet("VeterinaryFormVet1");
        }

        public ActionResult VeterinaryFormVet1A()
        {
            return VeterinaryFormVet("VeterinaryFormVet1A");
        }

        public ActionResult ShowVeterinaryFormVet1(VetCasesModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVeterinaryFormVet1((VetCasesSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "VeterinaryFormVet1",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult ShowVeterinaryFormVet1A(VetCasesModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVeterinaryFormVet1A((VetCasesSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "VeterinaryFormVet1A",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VeterinarySummaryAZ()
        {
            ViewBag.GetReportActionName = "ShowVeterinarySummaryAZ";
            ViewBag.Title = EidssMenu.Instance.GetString("VeterinarySummaryAZ");
            ViewBag.MaxCheckedCount = SummaryByRayonDiagnosisModel.VetMaxDiagnosisCount;
            return View("AZ/SummaryByRayonDiagnosis", new SummaryByRayonDiagnosisModel {CanWorkWithArchive = false, IsVet = true});
        }

        public ActionResult ShowVeterinarySummaryAZ(SummaryByRayonDiagnosisModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                model.IsVet = true;
                if (!bv.common.Core.Utils.IsEmpty(model.MultipleDiagnosisFilter_CheckedItems))
                {
                    model.MultipleDiagnosisFilter.CheckedItems =
                        model.MultipleDiagnosisFilter_CheckedItems.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                    //TODO отрезать избыточные диагнозы
                }

                var report = wrapper.Client.ExportVeterinarySummaryAZ(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Summary_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region AZ Lab Reports

        public ActionResult LabTestingResultsAZ()
        {
            ViewBag.GetReportActionName = "ShowLabTestingResultsAZ";
            ViewBag.Title = EidssMenu.Instance.GetString("LabTestingResultsAZ");
            return View("AZ/LabTestingResults", new VetLabSampleModel());
        }

        public ActionResult ShowLabTestingResultsAZ(VetLabSampleModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportLabTestingResultsAZ(model);
                resultParameters = new ReportResultParameters(report, "LabTestResultAZ",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult AssignmentLabDiagnosticAZ()
        {
            ViewBag.GetReportActionName = "ShowAssignmentLabDiagnosticAZ";
            ViewBag.Title = EidssMenu.Instance.GetString("AssignmentLabDiagnosticAZ");
            return View("AZ/AssignmentLabDiagnostic", new LabCaseModel());
        }

        public ActionResult ShowAssignmentLabDiagnosticAZ(LabCaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportAssignmentLabDiagnosticAZ(model);
                resultParameters = new ReportResultParameters(report, "AssignmentLabDiagnosticAZ",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region IQ Human Reports

        /*
        public ActionResult HumComparativeIQReport()
        {
            ViewBag.GetReportActionName = "ShowHumComparativeIQReport";
            ViewBag.Title = EidssMenu.Instance.GetString("HumComparativeIQReport");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("IQ/Comparative", new ComparativeIQModel { Address1 = address });
        }

        public FileContentResult ShowHumComparativeIQReport(ComparativeIQModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                byte[] report = wrapper.Client.ExportHumComparativeIQReport((ComparativeSurrogateModel)model);
                resultParameters = new ReportResultParameters(report, "Human_Comparative_Report",
                                                              model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }
        */

        #endregion

        #region GG Human Reports

        public ActionResult Hum60BJournal()
        {
            ViewBag.GetReportActionName = "ShowHum60BJournal";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsJournal60BReportCard");
            return View("GG/Hum60BJournal", new Hum60BJournalModel());
        }

        public ActionResult ShowHum60BJournal(Hum60BJournalModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHum60BJournal(model);
                resultParameters = new ReportResultParameters(report, "Human_60B_Journal",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumMonthInfectiousDiseaseNew()
        {
            ViewBag.GetReportActionName = "ShowHumMonthInfectiousDiseaseNew";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumInfectiousDiseaseMonthNew");
            var model = new MonthInfectiousDiseaseModel {IsMonthMandatory = true};
            return View("GG/MonthInfectiousDiseaseNew", model);
        }

        public ActionResult ShowHumMonthInfectiousDiseaseNew(MonthInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumMonthInfectiousDiseaseNew(model);
                resultParameters = new ReportResultParameters(report, "Human_Month_Infectious_Disease_New_Revision",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumIntermediateMonthInfectiousDiseaseNew()
        {
            ViewBag.GetReportActionName = "ShowHumIntermediateMonthInfectiousDiseaseNew";
            ViewBag.Title = EidssMenu.Instance.GetString("HumInfectiousDiseaseIntermediateMonthNew");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("GG/IntermediateInfectiousDisease", new IntermediateInfectiousDiseaseModel {Address = address});
        }

        public ActionResult ShowHumIntermediateMonthInfectiousDiseaseNew(IntermediateInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumIntermediateMonthInfectiousDiseaseNew(
                    (IntermediateInfectiousDiseaseSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Intermediate_Month_Infectious_Disease_New_Revision",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }
            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumAnnualInfectiousDisease()
        {
            ViewBag.GetReportActionName = "ShowHumAnnualInfectiousDisease";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumInfectiousDiseaseYear");
            return View("GG/AnnualInfectiousDisease", new AnnualInfectiousDiseaseModel());
        }

        public ActionResult ShowHumAnnualInfectiousDisease(AnnualInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumAnnualInfectiousDisease(model);
                resultParameters = new ReportResultParameters(report, "Human_Annual_Infectious_Disease",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumIntermediateAnnualInfectiousDisease()
        {
            ViewBag.GetReportActionName = "ShowHumIntermediateAnnualInfectiousDisease";
            ViewBag.Title = EidssMenu.Instance.GetString("HumInfectiousDiseaseIntermediateYear");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("GG/IntermediateInfectiousDisease", new IntermediateInfectiousDiseaseModel {Address = address});
        }

        public ActionResult ShowHumIntermediateAnnualInfectiousDisease(IntermediateInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumIntermediateAnnualInfectiousDisease(
                    (IntermediateInfectiousDiseaseSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Intermediate_Annual_Infectious_Disease",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }
            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumMonthInfectiousDisease()
        {
            ViewBag.GetReportActionName = "ShowHumMonthInfectiousDisease";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumInfectiousDiseaseMonth");
            var model = new MonthInfectiousDiseaseModel {IsMonthMandatory = true};
            return View("GG/MonthInfectiousDisease", model);
        }

        public ActionResult ShowHumMonthInfectiousDisease(MonthInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumMonthInfectiousDisease(model);
                resultParameters = new ReportResultParameters(report, "Human_Month_Infectious_Disease_Old_Revision",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumIntermediateMonthInfectiousDisease()
        {
            ViewBag.GetReportActionName = "ShowHumIntermediateMonthInfectiousDisease";
            ViewBag.Title = EidssMenu.Instance.GetString("HumInfectiousDiseaseIntermediateMonth");
            var address = new AddressModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("GG/IntermediateInfectiousDisease", new IntermediateInfectiousDiseaseModel {Address = address});
        }

        public ActionResult ShowHumIntermediateMonthInfectiousDisease(IntermediateInfectiousDiseaseModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                byte[] report = wrapper.Client.ExportHumIntermediateMonthInfectiousDisease(
                    (IntermediateInfectiousDiseaseSurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Human_Intermediate_Month_Infectious_Disease_Old_Revision",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }
            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region GG Lab Reports

        public ActionResult HumSerologyResearchCard()
        {
            ViewBag.GetReportActionName = "ShowHumSerologyResearchCard";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumSerologyResearchCard");
            return View("GG/HumanLabSample", new HumanLabSampleModel());
        }

        public ActionResult ShowHumSerologyResearchCard(HumanLabSampleModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumSerologyResearchCard(model);
                resultParameters = new ReportResultParameters(report, "Human_Lab_Serology_Research_Card",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumMicrobiologyResearchCard()
        {
            ViewBag.GetReportActionName = "ShowHumMicrobiologyResearchCard";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsHumMicrobiologyResearchCard");
            return View("GG/HumanLabSample", new HumanLabSampleModel());
        }

        public ActionResult ShowHumMicrobiologyResearchCard(HumanLabSampleModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumMicrobiologyResearchCard(model);
                resultParameters = new ReportResultParameters(report, "Human_Lab_Microbiology_Research_Card",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumAntibioticResistanceCard()
        {
            ViewBag.GetReportActionName = "ShowHumAntibioticResistanceCard";
            ViewBag.Title = EidssMenu.Instance.GetString("HumAntibioticResistanceCard");
            return View("GG/HumanLabSample", new HumanLabSampleModel());
        }

        public ActionResult ShowHumAntibioticResistanceCard(HumanLabSampleModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumAntibioticResistanceCard(model);
                resultParameters = new ReportResultParameters(report, "Human_Lab_Antibiotic_Resistanc_Card_NCDC",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult HumAntibioticResistanceCardLma()
        {
            ViewBag.GetReportActionName = "ShowHumAntibioticResistanceCardLma";
            ViewBag.Title = EidssMenu.Instance.GetString("HumAntibioticResistanceCardLma");
            return View("GG/VetLabSample", new VetLabSampleModel());
        }

        public ActionResult ShowHumAntibioticResistanceCardLma(VetLabSampleModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportHumAntibioticResistanceCardLma(model);
                resultParameters = new ReportResultParameters(report, "Human_Lab_Antibiotic_Resistanc_Card_LMA",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region Common Vet Reports

        public ActionResult VetYearlySituation()
        {
            ViewBag.GetReportActionName = "ShowVetYearlySituation";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsVetYearlySituation");
            return View("Common/BaseYear", new BaseYearModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowVetYearlySituation(BaseYearModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetYearlySituation(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Yearly_Situation",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetSamplesCount()
        {
            ViewBag.GetReportActionName = "ShowVetSamplesCount";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsVetSamplesCount");
            return View("Common/BaseYear", new BaseYearModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowVetSamplesCount(BaseYearModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetSamplesCount(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Samples_Count",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetSamplesBySampleType()
        {
            ViewBag.GetReportActionName = "ShowVetSamplesBySampleType";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsVetSamplesReportBySampleType");
            return View("Common/BaseYear", new BaseYearModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowVetSamplesBySampleType(BaseYearModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetSamplesBySampleType(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Samples_Count_By_SampleType",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetSamplesBySampleTypesWithinRegions()
        {
            ViewBag.GetReportActionName = "ShowVetSamplesBySampleTypesWithinRegions";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsVetSamplesReportBySampleTypesWithinRegions");
            return View("Common/BaseYear", new BaseYearModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowVetSamplesBySampleTypesWithinRegions(BaseYearModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetSamplesBySampleTypesWithinRegions(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Samples_Count_By_SampleType_Within_Regions",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetActiveSurveillance()
        {
            ViewBag.GetReportActionName = "ShowVetActiveSurveillance";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsActiveSurveillance");
            return View("Common/BaseYear", new BaseYearModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowVetActiveSurveillance(BaseYearModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetActiveSurveillance(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Active_Surveillance_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region KZ Vet Reports

        public ActionResult VetCountryPlannedDiagnosticTests()
        {
            ViewBag.GetReportActionName = "ShowVetCountryPlannedDiagnosticTests";
            ViewBag.Title = EidssMenu.Instance.GetString("VetCountryPlannedDiagnosticTestsReport");
            return View("KZ/DiagnosticInvestigationCountry", new DiagnosticInvestigationModel());
        }

        public ActionResult ShowVetCountryPlannedDiagnosticTests(DiagnosticInvestigationModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetCountryPlannedDiagnosticTests(model);

                resultParameters = new ReportResultParameters(report, "Veterinary_Country_Planned_Diagnostic_Tests_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetOblastPlannedDiagnosticTests()
        {
            ViewBag.GetReportActionName = "ShowVetOblastPlannedDiagnosticTests";
            ViewBag.Title = EidssMenu.Instance.GetString("VetRegionPlannedDiagnosticTestsReport");
            return View("KZ/DiagnosticInvestigationOblast", new DiagnosticInvestigationModel());
        }

        public ActionResult ShowVetOblastPlannedDiagnosticTests(DiagnosticInvestigationModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetOblastPlannedDiagnosticTests(model);

                resultParameters = new ReportResultParameters(report, "Veterinary_Oblast_Planned_Diagnostic_Tests_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetCountryPreventiveMeasures()
        {
            ViewBag.GetReportActionName = "ShowVetCountryPreventiveMeasures";
            ViewBag.Title = EidssMenu.Instance.GetString("VetCountryPreventiveMeasuresReport");
            return View("KZ/ProphylacticCountry", new ProphylacticModel());
        }

        public ActionResult ShowVetCountryPreventiveMeasures(ProphylacticModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetCountryPreventiveMeasures(model);

                resultParameters = new ReportResultParameters(report, "Veterinary_Country_Preventive_Measures_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetOblastPreventiveMeasures()
        {
            ViewBag.GetReportActionName = "ShowVetOblastPreventiveMeasures";
            ViewBag.Title = EidssMenu.Instance.GetString("VetRegionPreventiveMeasuresReport");
            return View("KZ/ProphylacticOblast", new ProphylacticModel());
        }

        public ActionResult ShowVetOblastPreventiveMeasures(ProphylacticModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetOblastPreventiveMeasures(model);

                resultParameters = new ReportResultParameters(report, "Veterinary_Oblast_Preventive_Measures_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetCountrySanitaryMeasures()
        {
            ViewBag.GetReportActionName = "ShowVetCountrySanitaryMeasures";
            ViewBag.Title = EidssMenu.Instance.GetString("VetCountryProphilacticMeasuresReport");
            return View("KZ/SanitaryCountry", new SanitaryModel());
        }

        public ActionResult ShowVetCountrySanitaryMeasures(SanitaryModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetCountrySanitaryMeasures(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Country_Sanitary_Measures_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetOblastSanitaryMeasures()
        {
            ViewBag.GetReportActionName = "ShowVetOblastSanitaryMeasures";
            ViewBag.Title = EidssMenu.Instance.GetString("VetRegionProphilacticMeasuresReport");
            return View("KZ/SanitaryOblast", new SanitaryModel());
        }

        public ActionResult ShowVetOblastSanitaryMeasures(SanitaryModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportVetOblastSanitaryMeasures(model);
                resultParameters = new ReportResultParameters(report, "Veterinary_Oblast_Sanitary_Measures_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region KZ Human Reports

        public ActionResult HumInfectiousParasiticKZ()
        {
            ViewBag.GetReportActionName = "ShowHumInfectiousParasiticKZ";
            ViewBag.Title = EidssMenu.Instance.GetString("HumInfectiousParasiticKZ");
            var model = new InfectiousParasiticKZModel(FilterHelper.GetDefaultRegion(), FilterHelper.GetDefaultRayon());
            return View("KZ/HumInfectiousParasiticKZ", model);
        }

        public ActionResult ShowHumInfectiousParasiticKZ(InfectiousParasiticKZModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                var report = wrapper.Client.ExportInfectiousParasiticKZReport((InfectiousParasiticKZSurrogateModel)model);
                resultParameters = new ReportResultParameters(report, "Human_Form_No_2",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region GG Vet Reports

        //VetLaboratoryResearchResult // VetLaboratoryResearchResult

        public ActionResult VetLaboratoryResearchResult()
        {
            ViewBag.GetReportActionName = "ShowVetLaboratoryResearchResult";
            ViewBag.Title = EidssMenu.Instance.GetString("VetLaboratoryResearchResult");
            return View("GG/VetLaboratoryResearchResult", new VetLaboratoryResearchResultModel());
        }

        public ActionResult ShowVetLaboratoryResearchResult(VetLaboratoryResearchResultModel model)
        {
            SelectListItemSurrogate csr =
                model.ConditionSampleReceivedList.FirstOrDefault(c => c.Value == model.cbConditionSampleReceived.ToString());
            if (csr != null && csr.Text.Length > 0)
            {
                model.ConditionSampleReceived = csr.Text;
            }

            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                byte[] report = wrapper.Client.ExportVetLaboratoryResearchResult(model);
                resultParameters = new ReportResultParameters(report, "Vet_Laboratory_Research_Result",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }
            return PrepareReportResult(resultParameters);
        }

        public ActionResult VetRabiesBulletinEurope()
        {
            ViewBag.GetReportActionName = "ShowVetRabiesBulletinEurope";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsVetRabiesBulletinEurope");
            return View("GG/VetRabiesBulletinEurope", new RBEModel());
        }

        public ActionResult ShowVetRabiesBulletinEurope(RBEModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                if (!bv.common.Core.Utils.IsEmpty(model.QuarterList))
                {
                    string[] quartersValues = model.QuarterList.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                    if (quartersValues.Length > 0)
                    {
                        List<int> q = quartersValues.Select(s => Convert.ToInt32(s)).ToList();
                        model.Quarters = new QuartersModel(q.Contains(1), q.Contains(2), q.Contains(3), q.Contains(4));
                    }
                }

                if (!bv.common.Core.Utils.IsEmpty(model.RegionList))
                {
                    model.Regions = model.RegionList.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                }

                if (!bv.common.Core.Utils.IsEmpty(model.RayonList))
                {
                    model.Rayons = model.RayonList.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                }

                byte[] report = wrapper.Client.ExportVetRabiesBulletinEurope((RBESurrogateModel) model);
                resultParameters = new ReportResultParameters(report, "Vet_Rabies_Bulletin_Europe_Report",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region Common Administrative Reports

        public ActionResult AdmEventLog()
        {
            ViewBag.GetReportActionName = "ShowAdmEventLog";
            ViewBag.Title = EidssMenu.Instance.GetString("ReportsAdmEventLog");
            return View("Common/BaseInterval", new BaseIntervalModel {CanWorkWithArchive = false});
        }

        public ActionResult ShowAdmEventLog(BaseIntervalModel model)
        {
            ReportResultParameters resultParameters;
            using (var wrapper = new ReportClientWrapper())
            {
                model.InitContextProperties();
                byte[] report = wrapper.Client.ExportAdmEventLog(model);
                resultParameters = new ReportResultParameters(report, "Administrative_Event_Log",
                    model.ExportFormatEnum.ToString(), model.IsOpenInNewWindow);
            }

            return PrepareReportResult(resultParameters);
        }

        #endregion

        #region Helper Methods

        private ActionResult PrepareReportResult(ReportResultParameters parameters)
        {
            var extension = parameters.FileExtension.ToLowerInvariant();
            var fullFileName = string.Format("{0}.{1}", parameters.FileName, extension);
            // this check because if call from  unit test HttpContext is null
            if (HttpContext != null)
            {
                HttpContext.Response.AddHeader("Content-Disposition",
                    string.Format("{0}; filename={1}", parameters.IsOpenInNewWindow ? "inline" : "attachment", fullFileName));
                Response.AppendHeader("Content-Type", "application/" + extension);
                Response.BinaryWrite(parameters.FileContents);
            }
            return new ContentResult();
        }

        #endregion
    }
}


text:
"use strict";
exports.pesoMock = {
    atleta: 'Paulo Mello',
    data: new Date(),
    peso: 80
};
//# sourceMappingURL=mock-peso.js.map

redpajama_set_name: RedPajamaGithub


text:
var Animations={
	linear:function(percent){
		return percent;
	},
	sine_curve:function(percent){
		return (1 - Math.cos(percent * Math.PI)) / 2;
	}
}


text:
    <navbar-directive></navbar-directive>

My Account

            Phone:

            Update phone number
            <input type="text" class="updateAcctData" ng-model="newPhone">
            <input type="submit" class="updateAcctData" ng-click="updatePhone()">

            Address:

            Update address
            <input type="text" class="updateAcctData">
            <input type="submit" class="updateAcctData">

            City:

            Update city
            <input type="text" class="updateAcctData">
            <input type="submit" class="updateAcctData">

            State:

            Update state
            <input type="text" class="updateAcctData">
            <input type="submit" class="updateAcctData">

            Zip Code:

            Update zip code
            <input type="text" class="updateAcctData">
            <input type="submit" class="updateAcctData">

            Email:

            Update email address
            <input type="text" class="updateAcctData" ng-model="newEmail">
            <input type="submit" class="updateAcctData">

            User Account Type:

            Group Name:

            Update group name
            <input type="text" class="updateAcctData" ng-model="newGroupName">
            <input type="submit" class="updateAcctData">


text:
from google.appengine.ext.webapp import template
import webapp2

class helpSeekerHandler(webapp2.RequestHandler):
	def get(self):
		template_params = {}

		html = template.render("web/templates/helpSeeker.html", template_params)
		self.response.write(html)

app = webapp2.WSGIApplication([
	('/helpSeeker', helpSeekerHandler)
], debug=True)


text:
@class FractionOperatorSet;
@class ExpressionElement;

@interface FractionEvaluator : NSObject

@property(nonatomic, strong) FractionOperatorSet *operatorsSet;

+ (instancetype)defaultFractionEvaluator;

- (Fraction*)evaluateString:(NSString *)exp error:(NSError *__autoreleasing*)error;
- (id)evaluateExpression:(ExpressionElement *)exp error:(NSError *__autoreleasing*)error;
@end


text:
package gov.nasa.arc.mct.satellite.component;

import gov.nasa.arc.mct.api.feed.DataProvider;
import gov.nasa.arc.mct.components.FeedProvider;
import gov.nasa.arc.mct.components.FeedProvider.RenderingInfo;
import gov.nasa.arc.mct.satellite.utilities.SatTrak;

import java.awt.Color;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

/*
 * This class takes-in data-feeds and then grabs the feed associated with a satellite coordinate component (it does
 * this by looking for the unique identifier that CoordinateComponent placed into its feeds).  With the feeds, this
 * class constructs the satellite data.
 *
 *   Note: The feeds contain TLE data, this class grabs that data and calculates the satellite data based on the TLEs
 *
 *   How does MCT know that this class is a dataProvider? Well, services.xml (found in OSGI-INF) tells MCT that this
 *   class reads feeds.
 */
public class SatelliteDataProvider implements DataProvider {

	//for the purpose of not re-creating already created satellites in the getData method
	private static final ThreadLocal<Map<String, SatTrak>> unique = new ThreadLocal<Map<String,SatTrak>>() {
            @Override protected Map<String, SatTrak> initialValue() {
                return new HashMap<String, SatTrak>();
        }
    };

	/*
	 * (non-Javadoc)
	 * @see gov.nasa.arc.mct.api.feed.DataProvider#isFullyWithinTimeSpan(java.lang.String, long, java.util.concurrent.TimeUnit)
	 *
	 * CoordinateComponent is the class making the FeedID
	 */
	@Override
	public boolean isFullyWithinTimeSpan(String feedID, long startTime,
			TimeUnit timeUnit) {
		if( feedID.startsWith(CoordinateComponent.FEED_KEY_ID) && feedID.contains(CoordinateComponent.FEED_SEPERATOR))
			return true;
		else
			return false;
	}

	/*
	 * This Satellite data provider can provide data fast
	 */
	@Override
	public LOS getLOS() {
		return LOS.fast;
	}

/*
 * This method reads the feeds comming off from CoordinateComponent.java (which is located in the package
 * gov.nasa.arc.mct.satellite.component)
 *
 * Notes: *	 	pieces[0] satellite name
 *  			pieces[1] TLE line 1
 *  			pieces[2] TLE line 2
 *  			pieces[3] position or velocity, of x y or z component
 *
 *        *		Do not change the value of the feedID, for doing so will confuse MCT; for example,  notice I used
 *         		String tleFeed = = feedID.substring(feedID.indexOf(":")+1), that is, a new variable rather than
 *         		writing over feedID
 */
	@Override
	public Map<String, SortedMap<Long, Map<String, String>>> getData(
			Set<String> feedIDs, long startTime, long endTime, TimeUnit timeUnit) {

		Map<String, SatTrak> createdSats = unique.get();

		Map<String, SortedMap<Long, Map<String, String>>> out = new HashMap<String, SortedMap<Long, Map<String, String>>>();

		for (String feedID : feedIDs) {
			if (feedID.startsWith(CoordinateComponent.FEED_KEY_ID) && feedID.contains(CoordinateComponent.FEED_SEPERATOR)) {

				String tleFeed = feedID.substring(feedID.indexOf(":")+1);//+1 so we do not include ':'
				String[] pieces = tleFeed.split(CoordinateComponent.FEED_SEPERATOR);//see notes above method for 'pieces' array
				boolean isVelocity = pieces[3].contains("v");
				SortedMap<Long, Map<String, String>> data = new TreeMap<Long, Map<String, String>>();

				for (long time = startTime; time < endTime; time += 1000) {

					double dataValue = 0.0;

					//pieces[2] is used as a key to the satellites in the hashmap
					String SatNum = pieces[2].split("\\s+")[1]; //the satellite number is the second token of the second line of the TLE; it is Unique

					//determine whether if we have already created the satellite
					SatTrak sat;
					if(createdSats.containsKey(SatNum)) {
						sat = createdSats.get(SatNum);
					}
					else { //we have not created this satellite yet
						sat = new SatTrak(pieces[0], pieces[1], pieces[2]);
						createdSats.put(SatNum, sat);	//note that the satellite number is unique
					}

					if( isVelocity) {
						double[] TEMEvel = sat.getTEMEvelocity(time);
						if (pieces[3].contains("x"))
							dataValue = TEMEvel[0];
						else if (pieces[3].contains("y"))
							dataValue = TEMEvel[1];
						else	// here we have (pieces[3].contains("z"))
							dataValue = TEMEvel[2];
					}
					else {
						if (pieces[3].contains("x"))
							dataValue = sat.getECEFx(time);
						else if (pieces[3].contains("y"))
							dataValue = sat.getECEFy(time);
						else	// (pieces[3].contains("z"))
							dataValue = sat.getECEFz(time);
					}

					//Now we pack our data so a View can use the data to display it to the user
					//as an example MercatorView takes this data and draws the satellite positions
					//on a Mercator graph
					Map <String, String> dataItem = new HashMap<String, String> ();
					RenderingInfo ri = new RenderingInfo(Double.toString(dataValue), Color.ORANGE, " ", Color.ORANGE, true);
					dataItem.put(FeedProvider.NORMALIZED_RENDERING_INFO, ri.toString());
					dataItem.put(FeedProvider.NORMALIZED_TIME_KEY,  Long.toString(time));
					dataItem.put(FeedProvider.NORMALIZED_VALUE_KEY, Double.toString(dataValue));
					dataItem.put(FeedProvider.NORMALIZED_TELEMETRY_STATUS_CLASS_KEY, "1");
					data.put(Long.valueOf(time), dataItem);
				}
				if (!data.isEmpty()) {
					out.put(feedID, data);
				}
			}
		}
		return out;
	}

	@Override
	public Map<String, List<Map<String, String>>> getData(Set<String> feedIDs,
			TimeUnit timeUnit, long startTime, long endTime) {
		// TODO Auto-generated method stub
		return null;
	}

}


text:
'use strict'

import React from 'react'

export const CoverallsInfo = React.createClass({
  propTypes: {
    coveralls: React.PropTypes.object.isRequired
  },

  render () {
    return (

 Coveralls

Name: {this.props.coveralls.name}

URL: {this.props.coveralls.url}

Coverage change: {this.props.coveralls.coverageChange}

Covered percent: {this.props.coveralls.coveredPercent}

Badge:

    )
  }
})

export default CoverallsInfo


text:
Ness Computing Scopes Component
===============================

Component Charter
-----------------

* Provides various special guice scopes.

Component Level
---------------

*Foundation component*

* Allowed dependencies: logging component.

----

ThreadDelegate scope
--------------------

Similar to the 'request' scope, except that it can be passed onto
another thread and is not tied to the (non-threadsafe) HttpRequest
object.

Activated by installing the ThreadDelegatedScopeModule.

----
Copyright (C) 2012 Ness Computing, Inc.


text:
package org.wso2.carbon.apimgt.rest.api.publisher;

import io.swagger.annotations.ApiParam;

import org.wso2.carbon.apimgt.rest.api.publisher.dto.ApplicationDTO;
import org.wso2.carbon.apimgt.rest.api.publisher.dto.ErrorDTO;
import org.wso2.carbon.apimgt.rest.api.publisher.factories.ApplicationsApiServiceFactory;

import org.wso2.msf4j.Microservice;
import org.wso2.msf4j.Request;
import org.wso2.msf4j.formparam.FileInfo;
import org.wso2.msf4j.formparam.FormDataParam;
import org.osgi.service.component.annotations.Component;

import java.io.InputStream;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

@Component(
    name = "org.wso2.carbon.apimgt.rest.api.publisher.ApplicationsApi",
    service = Microservice.class,
    immediate = true
)
@Path("/api/am/publisher/v1.[\\d]+/applications")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApplicationPath("/applications")
@io.swagger.annotations.Api(description = "the applications API")
public class ApplicationsApi implements Microservice  {
   private final ApplicationsApiService delegate = ApplicationsApiServiceFactory.getApplicationsApi();

    @GET
    @Path("/{applicationId}")
    @Consumes({ "application/json" })
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "Get details of an application", notes = "This operation can be used to retrieve details of an individual application specifying the application id in the URI. ", response = ApplicationDTO.class, tags={ "Application (Individual)", })
    @io.swagger.annotations.ApiResponses(value = {
        @io.swagger.annotations.ApiResponse(code = 200, message = "OK. Application returned. ", response = ApplicationDTO.class),

        @io.swagger.annotations.ApiResponse(code = 304, message = "Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). ", response = ApplicationDTO.class),

        @io.swagger.annotations.ApiResponse(code = 404, message = "Not Found. Requested application does not exist. ", response = ApplicationDTO.class),

        @io.swagger.annotations.ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported ", response = ApplicationDTO.class) })
    public Response applicationsApplicationIdGet(@ApiParam(value = "**Application Identifier** consisting of the UUID of the Application. ",required=true) @PathParam("applicationId") String applicationId
,@ApiParam(value = "Media types acceptable for the response. Default is application/json. " , defaultValue="application/json")@HeaderParam("Accept") String accept
,@ApiParam(value = "Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resourec. " )@HeaderParam("If-None-Match") String ifNoneMatch
,@ApiParam(value = "Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource. " )@HeaderParam("If-Modified-Since") String ifModifiedSince
, @Context Request request)
    throws NotFoundException {
        return delegate.applicationsApplicationIdGet(applicationId,accept,ifNoneMatch,ifModifiedSince, request);
    }
}


text:
"""Helper for OwnTracks."""
try:
    import nacl
except ImportError:
    nacl = None  # type: ignore[assignment]

def supports_encryption() -> bool:
    """Test if we support encryption."""
    return nacl is not None


text:
<!DOCTYPE html>

  <title>Eduard Grabchak</title>
  <meta charset="utf-8">
  <meta name="keywords" content="Eduard Grabchak">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">

Hello!

My name is Eduard Grabchak

I am a Web Developer

 About 2 years ago I started to learn coding and stopped on web development.

I really like my work. All my projects you can watch here.

Where To Find Me?

If you have any questions, you can contact me via:

       VK |
       Gmail

© edgrlab.github.io 2015 - 2017


text:
namespace Kentico.Kontent.Delivery.Benchmarks.ContentTypes
{
    public partial class AboutUs
    {
    }
}


text:
const assert = require('assert');
const fs = require('fs');

const dropSql = `do $$
begin
  create table if not exists foo ();
  execute (
    select string_agg('drop table if exists "' || table_name || '" cascade;', '')
    from information_schema.tables
    where
      table_schema = 'public' and table_type = 'BASE TABLE' and table_name <> 'spatial_ref_sys'
    );
end
$$;`;

const migrate = async (path, pool, isSync) => {
  assert(pool.query, 'Should have pool.query. Please use pg.Pool.');
  assert(pool.connect, 'Should have pool.connect. Please use pg.Pool');
  const hooks = [
    '0000-00-00T00:00:00:000Z',
    '9999-99-99T99:99:99:999Z',
  ];
  const isHook = migration => hooks.some(hook => migration.filename.startsWith(hook));

  const executeMigration = async (migration) => {
    const client = await pool.connect();
    try {
      await client.query('begin');
      await client.query(migration.sql);
      if (!isHook(migration)) {
        await client.query('insert into schema_info (version) values ($1)', [migration.filename]);
      }
      await client.query('commit');
    } catch (err) {
      await client.query('rollback');
      throw err;
    } finally {
      await client.release();
    }
  };

  const executeMigrations = async () => {
    const databaseSchemas = (await pool.query('select * from schema_info')).rows
      .map(schema => schema.version);
    const filesystemSchemas = fs.readdirSync(path).filter(file => file.endsWith('.sql')).sort();
    const newSchemas = filesystemSchemas.filter(schema => !databaseSchemas.includes(schema));
    const migrations = newSchemas
      .map(filename => ({ filename, sql: fs.readFileSync(`${path}/${filename}`, 'utf8') }));
    // We want to use await in a loop, because this executed the migrations in a sequence.
    // eslint-disable-next-line no-restricted-syntax
    for (const migration of migrations) {
      // eslint-disable-next-line no-await-in-loop
      await executeMigration(migration);
    }
    return migrations;
  };

  if (isSync) {
    await pool.query(dropSql);
  }
  await pool.query('create table if not exists schema_info (version text not null unique)');
  const migrations = await executeMigrations();
  return migrations.map(migration => `Added ${migration.filename} to database.`);
};
module.exports = migrate;


text:
local spec_helper = require "spec.spec_helpers"
local http_client = require "kong.tools.http_client"
local cjson = require "cjson"

local STUB_GET_URL = spec_helper.STUB_GET_URL
local STUB_POST_URL = spec_helper.STUB_POST_URL

describe("Request Transformer", function()
  setup(function()
    spec_helper.prepare_db()
    spec_helper.insert_fixtures {
      api = {
        {name = "tests-request-transformer-1", request_host = "test1.com", upstream_url = "http://mockbin.com"},
        {name = "tests-request-transformer-2", request_host = "test2.com", upstream_url = "http://httpbin.org"},
        {name = "tests-request-transformer-3", request_host = "test3.com", upstream_url = "http://mockbin.com"},
        {name = "tests-request-transformer-4", request_host = "test4.com", upstream_url = "http://mockbin.com"},
        {name = "tests-request-transformer-5", request_host = "test5.com", upstream_url = "http://mockbin.com"},
        {name = "tests-request-transformer-6", request_host = "test6.com", upstream_url = "http://mockbin.com"},
      },
      plugin = {
        {
          name = "request-transformer",
          config = {
            add = {
              headers = {"h1:v1", "h2:v2"},
              querystring = {"q1:v1"},
              body = {"p1:v1"}
            }
          },
          __api = 1
        },
        {
          name = "request-transformer",
          config = {
            add = {
              headers = {"host:mark"}
            }
          },
          __api = 2
        },
        {
          name = "request-transformer",
          config = {
            add = {
              headers = {"x-added:a1", "x-added2:b1", "x-added3:c2"},
              querystring = {"query-added:newvalue", "p1:a1"},
              body = {"newformparam:newvalue"}
            },
            remove = {
              headers = {"x-to-remove"},
              querystring = {"toremovequery"}
            },
            append = {
              headers = {"x-added:a2", "x-added:a3"},
              querystring = {"p1:a2", "p2:b1"}
            },
            replace = {
              headers = {"x-to-replace:false"},
              querystring = {"toreplacequery:no"}
            }
          },
          __api = 3
        },
        {
          name = "request-transformer",
          config = {
            remove = {
              headers = {"x-to-remove"},
              querystring = {"q1"},
              body = {"toremoveform"}
            }
          },
          __api = 4
        },
        {
          name = "request-transformer",
          config = {
            replace = {
              headers = {"h1:v1"},
              querystring = {"q1:v1"},
              body = {"p1:v1"}
            }
          },
          __api = 5
        },
        {
          name = "request-transformer",
          config = {
            append = {
              headers = {"h1:v1", "h1:v2", "h2:v1",},
              querystring = {"q1:v1", "q1:v2", "q2:v1"},
              body = {"p1:v1", "p1:v2", "p2:v1"}
            }
          },
          __api = 6
        }
      },
    }
    spec_helper.start_kong()
  end)

  teardown(function()
    spec_helper.stop_kong()
  end)

  describe("Test remove", function()
    it("should remove specified header", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test4.com", ["x-to-remove"] = "true", ["x-another-header"] = "true"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.headers["x-to-remove"])
      assert.equal("true", body.headers["x-another-header"])
    end)
    it("should remove parameters on url encoded form POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["toremoveform"] = "yes", ["nottoremove"] = "yes"}, {host = "test4.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.postData.params["toremoveform"])
      assert.equal("yes", body.postData.params["nottoremove"])
    end)
    it("should remove parameters from JSON body in POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["toremoveform"] = "yes", ["nottoremove"] = "yes"}, {host = "test4.com", ["content-type"] = "application/json"})
      local body = cjson.decode(cjson.decode(response).postData.text)
      assert.equal(200, status)
      assert.falsy(body["toremoveform"])
      assert.equal("yes", body["nottoremove"])
    end)
    it("should not fail if JSON body is malformed in POST", function()
      local response, status = http_client.post(STUB_POST_URL, "malformed json body", {host = "test4.com", ["content-type"] = "application/json"})
      local body = cjson.decode(response).postData.text
      assert.equal(200, status)
      assert.equal("malformed json body", body)
    end)
    it("should not fail if body is empty and content type is application/json in POST", function()
      local response, status = http_client.post(STUB_POST_URL, nil, {host = "test4.com", ["content-type"] = "application/json"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal('{}', body.postData.text)
      assert.equal("2", body.headers["content-length"])
    end)
    it("should not fail if body is empty in POST", function()
      local response, status = http_client.post(STUB_POST_URL, nil, {host = "test4.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.same({}, body.postData.params)
      assert.equal('', body.postData.text)
      assert.equal("0", body.headers["content-length"])
    end)
    it("should remove parameters on multipart POST", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, {["toremoveform"] = "yes", ["nottoremove"] = "yes"}, {host = "test4.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.postData.params["toremoveform"])
      assert.equal("yes", body.postData.params["nottoremove"])
    end)
    it("should remove queryString on GET if it exist", function()
        local response, status = http_client.post(STUB_POST_URL.."/?q1=v1&q2=v2", {hello = "world"}, {host = "test4.com"})
        local body = cjson.decode(response)
        assert.equal(200, status)
        assert.falsy(body.queryString["q1"])
        assert.equal("v2", body.queryString["q2"])
    end)
  end)

  describe("Test replace", function()
    it("should replace specified header if it exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test5.com", ["h1"] = "V", ["h2"] = "v2"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.headers["h1"])
      assert.equal("v2", body.headers["h2"])
    end)
    it("should not add as new header if header does not exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test5.com", ["h2"] = "v2"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.headers["h1"])
      assert.equal("v2", body.headers["h2"])
    end)
    it("should replace specified parameters in url encoded body on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["p1"] = "v", ["p2"] = "v1"}, {host = "test5.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should not add as new parameter in url encoded body if parameter does not exist on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["p2"] = "v1"}, {host = "test5.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should replace specified parameters in json body on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["p1"] = "v", ["p2"] = "v1"}, {host = "test5.com", ["content-type"] = "application/json"})
      local body = cjson.decode(cjson.decode(response).postData.text)
      assert.equal(200, status)
      assert.equal("v1", body["p1"])
      assert.equal("v1", body["p2"])
    end)
    it("should not fail if JSON body is malformed in POST", function()
      local response, status = http_client.post(STUB_POST_URL, "malformed json body", {host = "test5.com", ["content-type"] = "application/json"})
      local body = cjson.decode(response).postData.text
      assert.equal(200, status)
      assert.equal("malformed json body", body)
    end)
    it("should not add as new parameter in json if parameter does not exist on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {["p2"] = "v1"}, {host = "test5.com", ["content-type"] = "application/json"})
      local body = cjson.decode(cjson.decode(response).postData.text)
      assert.equal(200, status)
      assert.falsy(body["p1"])
      assert.equal("v1", body["p2"])
    end)
    it("should replace specified parameters on multipart POST", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, {["p1"] = "v", ["p2"] = "v1"}, {host = "test5.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should not add as new parameter if parameter does not exist on multipart POST", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, {["p2"] = "v1"}, {host = "test5.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should replace queryString on POST if it exist", function()
        local response, status = http_client.post(STUB_POST_URL.."/?q1=v&q2=v2", {hello = "world"}, {host = "test5.com"})
        local body = cjson.decode(response)
        assert.equal(200, status)
        assert.equal("v1", body.queryString["q1"])
        assert.equal("v2", body.queryString["q2"])
    end)
    it("should not add new queryString on POST if it does not exist", function()
        local response, status = http_client.post(STUB_POST_URL.."/?q2=v2", {hello = "world"}, {host = "test5.com"})
        local body = cjson.decode(response)
        assert.equal(200, status)
        assert.falsy(body.queryString["q1"])
        assert.equal("v2", body.queryString["q2"])
    end)
  end)

  describe("Test add", function()
    it("should add new headers", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.headers["h1"])
      assert.equal("v2", body.headers["h2"])
    end)
    it("should not change or append value if header already exists", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test1.com", h1 = "v3"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v3", body.headers["h1"])
      assert.equal("v2", body.headers["h2"])
    end)
    it("should add new parameter in url encoded body on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("world", body.postData.params["hello"])
      assert.equal("v1", body.postData.params["p1"])
    end)
    it("should not change or append value to parameter in url encoded body on POST when parameter exists", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("world", body.postData.params["hello"])
      assert.equal("v1", body.postData.params["p1"])
    end)
    it("should add new parameter in JSON body on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test1.com", ["content-type"] = "application/json"})
      local body = cjson.decode(cjson.decode(response).postData.text)
      assert.equal(200, status)
      assert.equal("world", body["hello"])
      assert.equal("v1", body["p1"])
    end)
    it("should not change or append value to parameter in JSON on POST when parameter exists", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test1.com", ["content-type"] = "application/json"})
      local body = cjson.decode(cjson.decode(response).postData.text)
      assert.equal(200, status)
      assert.equal("world", body["hello"])
      assert.equal("v1", body["p1"])
    end)
    it("should not fail if JSON body is malformed in POST", function()
      local response, status = http_client.post(STUB_POST_URL, "malformed json body", {host = "test1.com", ["content-type"] = "application/json"})
      local body = cjson.decode(response).postData.text
      assert.equal(200, status)
      assert.equal("malformed json body", body)
    end)
    it("should add new parameter on multipart POST", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, {}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.postData.params["p1"])
    end)
    it("should not change or append value to parameter on multipart POST when parameter exists", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, { hello = "world"}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("world", body.postData.params["hello"])
      assert.equal("v1", body.postData.params["p1"])
    end)
    it("should add new querystring on GET", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.queryString["q1"])
    end)
    it("should not change or append value to querystring on GET if querystring exists", function()
      local response, status = http_client.get(STUB_GET_URL, {q1 = "v2"}, {host = "test1.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v2", body.queryString["q1"])
    end)
    it("should not change the host header", function()
      local response, status = http_client.get(spec_helper.PROXY_URL.."/get", {}, {host = "test2.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("httpbin.org", body.headers["Host"])
    end)
  end)

  describe("Test append ", function()
    it("should add a new header if header does not exists", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.headers["h2"])
    end)
    it("should append values to existing headers", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1, v2", body.headers["h1"])
    end)
    it("should add new querystring if querystring does not exists", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v1", body.queryString["q2"])
    end)
    it("should append values to existing querystring", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.same({"v1", "v2"}, body.queryString["q1"])
    end)
    it("should add new parameter in url encoded body on POST if it does not exist", function()
      local response, status = http_client.post(STUB_POST_URL, {}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.same({"v1", "v2"}, body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should append values to existing parameter in url encoded body if parameter already exist on POST", function()
      local response, status = http_client.post(STUB_POST_URL, {p1 = "v0"}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.same({"v0", "v1", "v2"}, body.postData.params["p1"])
      assert.equal("v1", body.postData.params["p2"])
    end)
    it("should not fail if JSON body is malformed in POST", function()
      local response, status = http_client.post(STUB_POST_URL, "malformed json body", {host = "test6.com", ["content-type"] = "application/json"})
      local body = cjson.decode(response).postData.text
      assert.equal(200, status)
      assert.equal("malformed json body", body)
    end)
    it("should not change or append value to parameter on multipart POST", function()
      local response, status = http_client.post_multipart(STUB_POST_URL, {p1 = "v0"}, {host = "test6.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("v0", body.postData.params["p1"])
    end)
  end)

  describe("Test for remove, replace, add and append ", function()
    it("should remove a header", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com", ["x-to-remove"] = "true"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.headers["x-to-remove"])
    end)
    it("should replace value of header, if header exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com", ["x-to-replace"] = "true"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("false", body.headers["x-to-replace"])
    end)
    it("should not add new header if to be replaced header does not exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.headers["x-to-replace"])
    end)
    it("should add new header if missing", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("b1", body.headers["x-added2"])
    end)
    it("should not add new header if it already exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com", ["x-added3"] = "c1"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("c1", body.headers["x-added3"])
    end)
    it("should append values to existing headers", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("a1, a2, a3", body.headers["x-added"])
    end)
    it("should add new parameters on POST when query string key missing", function()
      local response, status = http_client.post(STUB_POST_URL, {hello = "world"}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("b1", body.queryString["p2"])
    end)
    it("should remove parameters on GET", function()
      local response, status = http_client.get(STUB_GET_URL, {["toremovequery"] = "yes", ["nottoremove"] = "yes"}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.queryString["toremovequery"])
      assert.equal("yes", body.queryString["nottoremove"])
    end)
    it("should replace parameters on GET", function()
      local response, status = http_client.get(STUB_GET_URL, {["toreplacequery"] = "yes"}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("no", body.queryString["toreplacequery"])
    end)
    it("should not add new parameter if to be replaced parameters does not exist on GET", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.falsy(body.queryString["toreplacequery"])
    end)
    it("should add parameters on GET if it does not exist", function()
      local response, status = http_client.get(STUB_GET_URL, {}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("newvalue", body.queryString["query-added"])
    end)
    it("should not add new parameter if to be added parameters already exist on GET", function()
      local response, status = http_client.get(STUB_GET_URL, {["query-added"] = "oldvalue"}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("oldvalue", body.queryString["query-added"])
    end)
    it("should append parameters on GET", function()
      local response, status = http_client.post(STUB_POST_URL.."/?q1=20", {hello = "world"}, {host = "test3.com"})
      local body = cjson.decode(response)
      assert.equal(200, status)
      assert.equal("a1", body.queryString["p1"][1])
      assert.equal("a2", body.queryString["p1"][2])
      assert.equal("20", body.queryString["q1"])
    end)
  end)
end)


text:
Please Log In

Register

            back to LogIn

        <form ng-if="!userOptions.newUser"
              name="login">
            <fieldset>

                    <input class="form-control"
                           placeholder="Username"
                           name="username"
                           ng-model="loginForm.username"
                           type="text" autofocus>

                    <input class="form-control"
                           placeholder="Password"
                           name="password"
                           ng-model="loginForm.password"
                           type="password">

            </fieldset>
            Register
            <button type="button"
                    class="btn btn-success pull-right"
                    ng-click="sendCredentials()">Log In
            </button>

        </form>