public void SetPlusValues() { try { //DataTable metaFields = new SGBD().Cmd("select *, JSON_VALUE(JSON_DATA,'$.DEFAULT') as 'DEFAULT' from META_FIELD where META_BO_ID = " + this.MetaBoID // + " AND JSON_VALUE(JSON_DATA,'$.DEFAULT') like '%[+%]%'"); DataTable metaFields = new SGBD().Cmd("select * from META_FIELD where META_BO_ID = " + this.MetaBoID + " AND JSON_DATA like '%\"DEFAULT\":%[+%]%' "); foreach (DataRow mf in metaFields.Rows) { if (this.Items.ContainsKey(mf["DB_NAME"].ToString())) { var jsonData = JsonConvert.DeserializeObject <Dictionary <string, string> >(mf["JSON_DATA"].ToString()); var df = new MetaFieldRepo().GetDefaultValue(jsonData["DEFAULT"].ToString(), this.MetaBO.BO_DB_NAME, 1); if (df.type != "error") { this.Items[mf["DB_NAME"].ToString()] = df.value; } } } } catch (Exception) { } }
public async Task <IHttpActionResult> GetDefaultValue(string format, string boName) { //string cle = "", formule = "", step = "", type = ""; //bool inFomule = false; //int count = 0; //foreach (char car in format) //{ // if (car == '[') // { // formule += car; // inFomule = true; // continue; // } // if (car == ']') // { // formule += car; // inFomule = false; // continue; // } // if (inFomule) // { // formule += car; // count++; // if (count == 1) // { // switch (car) // { // case '+': // type = "plus"; // break; // case 'd': // type = "date"; // break; // } // } // else // { // step += car; // } // } // else // { // cle += car; // } //} //switch (type) //{ // case "plus": // var rst = db.PlusSequenceNextID(cle, boName, int.Parse(step), 0).ToList()[0]; // return Ok(new { type, value = format.Replace(formule, rst.ToString()) }); // case "date": // return Ok(new { type, value = step == "" ? DateTime.Now : DateTime.Now.AddDays(int.Parse(step)) }); // default: // return BadRequest("Formule non prise en charge !"); //} var df = new MetaFieldRepo().GetDefaultValue(format, boName, 0); if (df.type == "error") { return(BadRequest(df.msg)); } else { return(Ok(df)); } }