// POST: api/DocTucThoiGetResult public string Post(DocTucThoi value) { try { if (dicAppSet == null || dicAppSet.Count == 0) { general gn = new general(); dicAppSet = gn.ReadAppseting(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } } if (value == null || value.config == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } var json = ""; gnDocTucThoi orc = new gnDocTucThoi(); json = orc.getResultDocTucThoi(value.config, value.para, dicAppSet); return(json); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// POST: api/DocTucThoi_ChecDangDoc public string Post(DocTucThoi value) { try { Dictionary <string, string> dicAppSet = null; if (dicAppSet == null || dicAppSet.Count == 0) { general gn = new general(); dicAppSet = gn.ReadAppseting(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } } gnSqlNomal sqln = new gnSqlNomal(); var strfileInfo = File.ReadAllText(dicAppSet["dtt_infodoctucthoi"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); var files = Directory.GetFiles(dicFileInfo["dtt_savefiletofolder"]); return(files.Length > 0 ? "{\"result\":\"OK\",\"data\":\"Đang trong quá trình đọc tức thời\"}" : "{\"result\":\"OK\",\"data\":\"\"}"); }catch (Exception ex) { return(""); } }
// POST: api/DocTucThoiUpdateCmd public string Post(DocTucThoi value) { try { gnDocTucThoi orc = new gnDocTucThoi(); var json = orc.ExcuteDocTucThoi(value); return(json); } catch (Exception ex) { return(""); } }
// POST: api/DocTucThoi_CheckError public string Post(DocTucThoi value) { try { Dictionary <string, string> dicAppSet = null; Dictionary <string, string> dicProce = null; if (dicAppSet == null || dicAppSet.Count == 0) { general gn = new general(); dicAppSet = gn.ReadAppseting(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } } if (value == null || value.config == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } var json = ""; gnSqlNomal sqln = new gnSqlNomal(); var dicConfig = sqln.convertConfigToDic(value.config); var dicPara = sqln.convertParaToDic(value.para); var strfileInfo = File.ReadAllText(dicAppSet["dtt_infodoctucthoi"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); var fileExists = dicFileInfo["pathwritefilealltext"] + "\\" + dicPara["namefile"]; var lines = File.Exists(fileExists) ? File.ReadAllLines(fileExists) : null; if (lines == null) { return(""); } foreach (var line in lines) { var sp = line.Split(new string[] { "<==", "==>" }, StringSplitOptions.None); if (line.ToLower().IndexOf("dcu0") >= 0) { return("{\"result\":\"DCU0\",\"data\":\"\"}"); break; } if (line.ToLower().IndexOf("stopall") >= 0) { return("{\"result\":\"StopAll\",\"data\":\"" + (sp.Length > 1? sp[1].Replace("(StopAll)", ""):"") + "\"}"); break; } if (line.ToLower().IndexOf("readfail") >= 0 && line.ToLower().IndexOf(dicPara["socongto"]) >= 0) { return("{\"result\":\"ReadFail\",\"data\":\"" + dicPara["socongto"] + "\"}"); break; } if (line.ToLower().IndexOf("read meter success") >= 0) { return("{\"result\":\"Read Meter Success\",\"data\":\"\"}"); break; } } return(""); } catch (Exception ex) { return(""); } }
public string ExcuteDocTucThoi(DocTucThoi value) { Dictionary <string, string> dicAppSet = new Dictionary <string, string>(); try { if (dicAppSet == null || dicAppSet.Count == 0) { general gn = new general(); dicAppSet = gn.ReadAppseting(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } } if (value == null || value.config == null) { return("{\"result\":\"ERROR\",\"data\":\"Kiểm tra lại định dạng json đầu vào\"}"); } //var json = ""; //gnDocTucThoi orc = new gnDocTucThoi(); //json = orc.ExcuteDocTucThoi(value.config, value.para, dicAppSet); //return json; } catch (Exception ex) { general.WriterLogTracking(ex.Message, dicAppSet); return(""); } try { gnSqlNomal sqln = new gnSqlNomal(); var dicConfig = sqln.convertConfigToDic(value.config); var dicPara = sqln.convertParaToDic(value.para); // doc file json var strfileInfo = File.ReadAllText(dicAppSet["dtt_infodoctucthoi"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); if (dicPara == null && dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":\"Kiểm tra lại định dạng json đầu vào\"}"); } if (!dicPara.ContainsKey("v_imei")) { return("{\"result\":\"ERROR\",\"data\":\"Kiểm tra lại định dạng json đầu vào\"}"); } return(SaveFileToFolderFix(dicAppSet, dicFileInfo, dicConfig, dicPara)); // khong xoa vi tam thoi fix ip / port //if (dicFileInfo["dtt_connectto"].ToUpper() == "ORACLE") //{ // return "{\"result\":\"ERROR\",\"data\":\"Hiện trưa hỗ trợ oracle\"}"; // var lstPara = dicParaToOracleDocTucThoi(dicPara); // var oracle = new gnOracle(); // var json = oracle.ExcuteReturnDataSet(dicFileInfo["dtt_procedureoracle"], lstPara, CommandType.StoredProcedure, dicAppset["connectoracle"]); //} //if (dicFileInfo["dtt_connectto"].ToUpper() == "SQL") //{ // var sql = new gnSql(); // var gn = new general(); // // lay ra port tuong ung imei // var conn = dicAppset[dicConfig["connstr"].ToString().ToLower()]; // var lstPara = gn.ConvertDicToSqlPara(dicPara); // var dsPort = sql.DynamicSelectDataset(dicFileInfo["dtt_proceduresql"], lstPara, CommandType.StoredProcedure, conn); // if (dsPort == null || dsPort.Tables.Count == 0) // return "{\"result\":\"ERROR\",\"data\":\"Không tìm thấy thông tin ip/port\"}"; // // lay ra ip tuong ung o ifcsmart // var lstParaPort = ConvertDatatableToSqlPara(dsPort.Tables[0]); // var dsIpPort = sql.DynamicSelectDataset("DOCTUCTHOI_GetInfoIpPort", lstParaPort, CommandType.StoredProcedure, dicAppset["ifcsmart"]); // if (dsIpPort == null || dsIpPort.Tables.Count == 0) // return "{\"result\":\"ERROR\",\"data\":\"Không tìm thấy thông tin ip/port\"}"; // return SaveFileToFolder(dicAppset, dicFileInfo, dicConfig, dicPara, dsIpPort.Tables[0], dsPort.Tables[0]); //} // v_IMEI: "8661040203522850", //v_SoCongTo: "001502000145", //v_Ip: "", //v_Port: "" } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }