Пример #1
0
    bool UploadFiles(out string errorMessage)
    {
        errorMessage = null;
        bool   ok         = true;
        string contextKey = "DEACONTEXT";

        try
        {
            string warningMessage = null;
            Session.Remove(contextKey);
            string projColName = ConfigurationManager.AppSettings["csvProjectIDColumnName"];
            if (string.IsNullOrEmpty(projColName))
            {
                projColName = "Project";
            }
            DEAContext context = new DEAContext("DEAContext", projColName);

            ok = context.LoadVariablesFromCsvFile(VarFilePath, out errorMessage);
            if (ok)
            {
                ok = context.UploadCsvFile(ProjFilePath, out warningMessage, out errorMessage);
            }
            if (ok && !string.IsNullOrEmpty(ConstFilePath))
            {
                ok = context.LoadCsvConstraints(ConstFilePath, out errorMessage);
            }

            Session[contextKey] = context;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
            ok           = false;
        }
        return(ok);
    }
Пример #2
0
        public void TestVACsvDataUnconstrained()
        {
            string errorMessage   = null;
            string warningMessage = null;

            string csvFilePath      = @"C:\Projects\NCHRP 08-103\VA_TEST_PROJECTS.csv";
            string csvConstFilePath = @"C:\Projects\NCHRP 08-103\VA_TEST_CONSTRAINTS.csv";
            string csvVarFilePath   = @"C:\Projects\NCHRP 08-103\VA_TEST_VARIABLES.csv";
            string xmlFilePath      = @"C:\Projects\NCHRP 08-103\VA_TEST-3.xml";
            string xmlFilePath2     = @"C:\Projects\NCHRP 08-103\VA_TEST-4.xml";

            bool       ok      = true;
            DEAContext context = new DEAContext("DEAContext", "Project");

            ok = context.LoadVariablesFromCsvFile(csvVarFilePath, out errorMessage);
            if (ok)
            {
                ok = context.UploadCsvFile(csvFilePath, out warningMessage, out errorMessage);
            }

            if (ok)
            {
                ok = context.LoadCsvConstraints(csvConstFilePath, out errorMessage);
            }
            if (ok)
            {
                ok = context.RunDEA(out errorMessage);
            }


            if (ok)
            {
                ok = context.ApplyCostConstraintsToProjectSelection(out errorMessage);
            }

            Assert.IsTrue(ok, errorMessage);

            if (ok)
            {
                DataSet ds = context.ToDataSet(out errorMessage);
                Assert.IsNotNull(ds, errorMessage);
                ok = ds != null;
            }

            if (ok)
            {
                ok = context.SaveToXmlFile(xmlFilePath, out errorMessage);
                Assert.IsTrue(ok, errorMessage);
            }

            if (ok)
            {
                DEAContext context2 = DEAContext.CreateFromXmlFile(xmlFilePath, out errorMessage);
                Assert.IsNotNull(context2, errorMessage);
                if (context2 != null)
                {
                    ok = context2.SaveToXmlFile(xmlFilePath2, out errorMessage);
                    Assert.IsTrue(ok, errorMessage);
                }
            }

            if (ok)
            {
                string json = context.ToJsonString(out errorMessage);
                Assert.IsNotNull(json, errorMessage);
            }
        }