示例#1
0
文件: Map.cs 项目: solrac68/OPL
        /// <summary>
        /// Se almacena en un dictionario el resultado del proceso de cálculo del OPL
        /// </summary>
        /// <param name="dataOpti">Información de entrada.</param>
        /// <param name="result">Resultado.</param>
        /// <param name="failed">Falló</param>
        /// <param name="error">Error</param>
        /// <param name="ok">Proceso exitoso</param>
        /// <returns></returns>
        public static Dictionary <string, object> DataOptiToDic(DataOpti dataOpti, String result, String failed, String error, String ok)
        {
            Dictionary <string, object> dictResponse = new Dictionary <string, object>();

            dictResponse.Add("codCaso", dataOpti.CodCaso);
            dictResponse.Add("jobMRID", dataOpti.JobMRID);
            dictResponse.Add("proceso", dataOpti.Proceso);
            dictResponse.Add("fechaOperativa", dataOpti.FechaOperativa.ToString("s"));
            dictResponse.Add("fechaFincalculo", dataOpti.FechaFincalculo.ToString("s"));
            dictResponse.Add("fileId", dataOpti.FileId);

            result = result.Replace("\n", string.Empty).Replace("\r", string.Empty).Replace("\u003C", string.Empty).Replace("\u003E", string.Empty);

            dictResponse.Add("result", result);

            if (result.Contains(ok))
            {
                dictResponse.Add("state", "OK");
            }
            else if (result.Contains(error))
            {
                dictResponse.Add("state", "ERROR");
            }
            else if (result.Contains(failed))
            {
                dictResponse.Add("state", "FAILED");
            }
            else
            {
                dictResponse.Add("State", "UNDETERMINATED");
            }

            return(dictResponse);
        }
示例#2
0
        private void Dequeue_mensaje(object sender, string e)
        {
            Dictionary <string, object> dictResponse = new Dictionary <string, object>();
            String  jsonResponse;
            Enqueue enqueue;

            _logger.LogInformation("\n\n[x] Received {0}\n", e);

            DataOpti dataOpti = Map.StrToDataOpti(e);

            Optimization opt = Optimization.Instance;

            opt.ARCHIVO = this._ARCHIVO;
            opt.DATA    = this._DATA;
            opt.DATADIR = this._DATADIR;

            String result = opt.Execute(dataOpti.CodCaso, dataOpti.Proceso);

            dataOpti.FechaFincalculo = DateTime.Now;

            dictResponse = Map.DataOptiToDic(dataOpti, result, this._FAILED, this._ERROR, this._OK);

            jsonResponse = JsonSerializer.Serialize <Dictionary <string, object> >(dictResponse);

            _logger.LogInformation(" [x] Resultados: \n{0}\n", jsonResponse);

            enqueue = new Enqueue(_COLARESULTADO, _SERVER, this._USERQUEUE, this._PASSQUEUE, this._PORTQUEUE);

            enqueue.add(jsonResponse);
        }