// GET: api/Check_CheckAllProcess public string Get() { gnSqlNomal sqln = new gnSqlNomal(); general gn = new general(); var dicAppSet = gn.ReadAppseting(); if (!dicAppSet.ContainsKey("pathcheckserver")) { return("{\"status\":\"Không chứa pathcheckserver\"}"); } var strfileInfo = File.ReadAllText(dicAppSet["pathcheckserver"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); var str = ""; foreach (Process p in Process.GetProcesses(".")) { try { var name = p.MainWindowTitle != "" ? p.MainWindowTitle : p.ProcessName; str += "{\"name\":\"" + name + "\",\"status\":\"" + (p.Responding ?"Runing":"NotRespond") + "\",\"istype\":\"GetAllProcess\",\"servername\":\"" + dicFileInfo["servername"] + "\"},"; } catch { } } var sum = str != "" ? str.Substring(0, str.Length - 1) : ""; return("[" + sum + "]"); }
// GET api/sqlsysdnpc/5 public string Get(string id) { WS ws = new WS(); general gn = new general(); var json = ws.GetGia(id, "dnpc@"); var dt = gn.ConvertJsonToDataTable(json, "dt"); if (dt != null && dt.Rows.Count > 0) { var prDt = new SqlParameter("@dt", SqlDbType.Structured); prDt.Value = dt; var parameters = new[] { prDt }; // ExecuteSqlDataset("[DNPC].[AutoInsertGiaDien]", parameters); } //for (int i = 0; i <= 3; i++) //{ // var thu = DateTime.Now.AddMonths(-i).Month; // var thu1 = DateTime.Now.AddMonths(-i).Year; // var dt1 = ws.GetCP(id, DateTime.Now.AddMonths(-i).Month, DateTime.Now.AddMonths(-i).Year,1, "dnpc@"); // if (dt1 != null && dt1.Rows.Count > 0) // { // ds.Tables.Add(dt1); // } //} //var data = gn.ConvertDatasetToListJson(ds); //if (data == null) return "{\"result\":\"ERROR\",\"data\":\"Lỗi khi ConvertDatasetToListJson\"}"; //json += gn.ConvertListToJson(data); return(json); }
//get All text public string getResultAllTextDocTucThoi(string config, string para, Dictionary <string, string> dicAppset) { try { gnSqlNomal sqln = new gnSqlNomal(); general gn = new general(); var dicAppSet = gn.ReadAppseting(); var dicConfig = sqln.convertConfigToDic(config); var dicPara = sqln.convertParaToDic(para); var strfileInfo = File.ReadAllText(dicAppSet["dtt_infodoctucthoi"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); var fileExists = dicFileInfo["pathwritefilealltext"] + "\\" + dicConfig["namefile"]; var lines = File.Exists(fileExists) ? File.ReadAllText(fileExists) : "[]"; // var lines = File.ReadAllText(fileExists); return("{\"result\":\"OK\",\"data\":\"" + lines + "\"}"); } catch (Exception ex) { return(ex.Message); } }
public JsonResult UploadFileDaKy() { try { general gn = new general(); var dicAppSet = gn.ReadAppseting(); string fileName = ""; for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; //Uploaded file //Use the following properties to get file's name, size and MIMEType int fileSize = file.ContentLength; fileName = file.FileName; string mimeType = file.ContentType; System.IO.Stream fileContent = file.InputStream; //To save file, use SaveAs method //file.SaveAs(dicAppSet["hddt_path_downloadfilehoadon"] + fileName); file.SaveAs(dicAppSet["hddt_path_filehoadondaky"] + fileName); // var pathSave = Server.MapPath("~/UploadFile/") ; // file.SaveAs(Server.MapPath(pathSave)); //File will be saved in application root } var strResult = Json("{\"result\":\"OK\",\"data\":\"" + fileName + "\"}"); return(strResult); // return Json("{\"result\":\"OK\",\"data\":\"Không nhận được file\"}"); } catch (Exception ex) { return(Json("{\"result\":\"ERROR\",\"data\":\"" + ex.Message + "\"}")); } }
// 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(""); } }
// GET: api/Check_CheckDrives public string Get() { // Check Ổ đĩa var sum = ""; gnSqlNomal sqln = new gnSqlNomal(); general gn = new general(); var dicAppSet = gn.ReadAppseting(); if (!dicAppSet.ContainsKey("pathcheckserver")) { return("{\"status\":\"Không chứa pathcheckserver\"}"); } var strfileInfo = File.ReadAllText(dicAppSet["pathcheckserver"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); DriveInfo[] allDrives = DriveInfo.GetDrives(); var str = ""; foreach (DriveInfo d in allDrives) { try { str += "{\"driver\":\"" + d.Name.Substring(0, 1) + "\",\"totalfreespace\":\"" + Math.Round(Convert.ToDouble(d.TotalFreeSpace) / 1073741824) + " GB\",\"totalsize\":\"" + Math.Round(Convert.ToDouble(d.TotalSize) / 1073741824) + " GB\",\"istype\":\"CheckDrive\",\"servername\":\"" + dicFileInfo["servername"] + "\"},"; } catch { } } sum = str != "" ? str.Substring(0, str.Length - 1) : ""; return("[" + sum + "]"); }
public JsonResult MCF_Upload_Firmware() { try { general gn = new general(); var dicAppSet = gn.ReadAppseting(); string fileName = ""; HttpPostedFileBase file = Request.Files[0]; int fileSize = file.ContentLength; fileName = file.FileName; string mimeType = file.ContentType; System.IO.Stream fileContent = file.InputStream; var strResult = Json("{\"result\":\"OK\",\"data\":\"OK\"}"); if (!System.IO.File.Exists(dicAppSet["mcf_path_firmware"] + fileName)) { file.SaveAs(dicAppSet["mcf_path_firmware"] + fileName); strResult = Json("{\"result\":\"OK\",\"data\":\"" + fileName + "\"}"); } else { strResult = Json("{\"result\":\"ERROR\",\"data\":\"Đã tồn tại, vui lòng chọn firmware khác hoặc xóa file cũ trước khi upload\"}"); } //string fullpath = dicAppSet["mcf_path_firmware"] + fileName; //fullpath = Regex.Replace(fullpath, @"\\", @"\\"); return(strResult); // return Json("{\"result\":\"OK\",\"data\":\"Không nhận được file\"}"); } catch (Exception ex) { return(Json("{\"result\":\"ERROR\",\"data\":\"" + ex.Message + "\"}")); } }
// 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/ExcuteOracle public string Post(ValueModelOracle value) { 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\"}]}"); } Db_Access ac = new Db_Access(); var check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.config, value.para); if (!check) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}"); } var json = ""; gnOracleXml orc = new gnOracleXml(); json = orc.ExcuteStores(value.config, value.para, dicAppSet); return(json); }
// POST: api/Convert_HtmlToWord public string Post(HtmlToWord value) { try { Dictionary <string, string> dicAppSet; general gn = new general(); dicAppSet = gn.ReadAppseting(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } var dicConfig = gn.ConfigConvertToDicConfig(value.config); if (dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } getTextInHtml html = new getTextInHtml(); string data = html.GetHTMLfromUrl(dicConfig["fromurl"]); NoInkSoftware.HTMLtoDOCX NewFile = new NoInkSoftware.HTMLtoDOCX(); var namefile = dicAppSet["path_saveonserver"] + dicConfig["namefile"]; NewFile.CreateFileFromHTML(data, namefile); return("{\"result\":\"OK\",\"data\":\"" + namefile + "\"}"); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// POST: api/BulkCopySqlRenameCol public string Post(paraExportXml value) { try { general gn = new general(); var json = ""; var dicConfig = gn.ConfigConvertToDicConfig(value.config); if (dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } var table = JObject.Parse(value.para); if (table == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } gnSqlNomal gns = new gnSqlNomal(); var para = gns.convertParaToDic(value.para); DataTable dt = new DataTable("dt"); foreach (var val in table) { dt = gn.ConvertJsonToDataTable(val.Value.ToString(), val.Key); break; } gn.ExportTable(dt, dicConfig); return(json); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// POST: api/ExcuteText public string Post(ValueText value) { if (value == null || value.connstr == null || value.connstr == "" || value.sqltext == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } general gns = new general(); var dicAppSet = gns.ReadAppseting(); Db_Access ac = new Db_Access(); var check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, value.sqltext, ""); if (!check) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không cho phép request liên tục\"}]}"); } var dicConfig = new Dictionary <string, string>(); dicConfig.Add("connstr", value.connstr); dicConfig.Add("namesql", value.sqltext); dicConfig.Add("commandtype", "Text"); var json = ""; gnOracle orc = new gnOracle(); json = orc.ExcuteReturnJson(dicConfig, null); return(json); }
// GET api/Xml_ExportOracle/5 public HttpResponseMessage Get(string idrandom) { general gn = new general(); var dicAppSet = gn.ReadAppseting(); var lst = JObject.Parse(_dicPara_xml["StrColumnNames" + idrandom]).SelectToken("kq").ToString(); var LstColumnNames = JsonConvert.DeserializeObject <List <ListColumnExport> >(lst); // lay du lieu gnOracle or = new gnOracle(); if (dicAppSet == null || dicAppSet.Count == 0) { return(null); } var dicPara = gn.ParaConvertDicPara(_dicPara_xml["StrPara" + idrandom]); var dicConfig = gn.ConfigConvertToDicConfig(_dicPara_xml["StrConfig" + idrandom]); if (dicPara == null && dicConfig == null) { return(null); } _dicPara_xml.Remove("StrPara" + idrandom); _dicPara_xml.Remove("StrConfig" + idrandom); _dicPara_xml.Remove("StrColumnNames" + idrandom); var dsParaOnSql = or.DecodeProceduePara_New(dicConfig, dicAppSet); var paraOk = or.dicParaToOraclePara_New(dsParaOnSql, dicPara); var ds = or.ExcuteReturnDataSet(dicConfig["namesql"], paraOk.ToList(), CommandType.StoredProcedure, dicAppSet[dicConfig["connstr"].ToLower()]); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return(null); } var ds1 = gn.convertDatasetToLower(ds); string filePath = dicAppSet["path_saveonserver"] + dicConfig["namefile"] + ".xml"; System.IO.StreamWriter xmlSW = new System.IO.StreamWriter(filePath); ds1.WriteXml(xmlSW, XmlWriteMode.WriteSchema); xmlSW.Close(); var response = new HttpResponseMessage(); FileStream fileStream = File.Open(filePath, FileMode.Open); response.Content = new StreamContent(fileStream); response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentDisposition.FileName = dicConfig["namefile"] + ".xml"; response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentLength = fileStream.Length; return(response); //return System.Web.Mvc.Controller.(filePath, MimeMapping.GetMimeMapping(filePath)); }
// POST: api/Email_SendMail public string Post(EmailValue value) { try { gnSqlNomal gn = new gnSqlNomal(); general gns = new general(); var dicAppSet = gns.ReadAppseting(); if (value == null || value.config == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại dữ liệu đầu vào\"}]}"); } var config = gn.convertConfigToDic(value.config); var ToEmail = config["sendtomail"]; var ToEmailCC = config["sendcctomail"]; MailMessage mail = new MailMessage(); mail.From = new MailAddress(dicAppSet["email_guithuc"], config["tenthaythe"]); String[] tmp = ToEmail.Split(','); foreach (string amail in tmp) { if (amail.Length > 0) { mail.To.Add(amail); } } foreach (string amail in ToEmailCC.Split(',')) { if (amail.Length > 0) { mail.CC.Add(amail); } } mail.Subject = config["chude"].ToString(); mail.Priority = MailPriority.High; mail.Body = config["noidung"].ToString(); mail.ReplyTo = new MailAddress(dicAppSet["email_guithuc"]); mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; SmtpClient mySmtpClient = new SmtpClient(); mySmtpClient.Host = dicAppSet["email_smtp"]; mySmtpClient.Credentials = new System.Net.NetworkCredential(dicAppSet["email_emailsend"], dicAppSet["email_passsend"]); mySmtpClient.EnableSsl = dicAppSet["email_ssl"] == "true" ? true : false; mySmtpClient.Port = Convert.ToInt32(dicAppSet["email_port"]); mySmtpClient.Send(mail); return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Gửi mail thành công\"}]}"); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message + "\"}]}"); } }
public string Post(ValueExportXml value) { general gn = new general(); var dicAppSet = gn.ReadAppseting(); _dicPara_xml.Add("StrPara" + value.idrandom, value.para); _dicPara_xml.Add("StrConfig" + value.idrandom, value.config); _dicPara_xml.Add("StrColumnNames" + value.idrandom, value.colum); return(""); }
public string ExcuteReturnJson(Dictionary <string, string> dicConfig, List <OracleParameter> lstOrlPara) { OracleConnection conn = null; OracleCommand cmd = null; OracleDataAdapter adapter = null; try { string connectOracle = ConfigurationManager.ConnectionStrings[dicConfig["connstr"]].ConnectionString; conn = new OracleConnection(connectOracle); conn.Open(); cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = dicConfig["namesql"]; cmd.CommandType = dicConfig.ContainsKey("commandtype") && dicConfig["commandtype"].ToLower() == "text" ? CommandType.Text: CommandType.StoredProcedure; cmd.BindByName = true; if (lstOrlPara != null) { cmd.Parameters.AddRange(lstOrlPara.ToArray()); } adapter = new OracleDataAdapter(cmd); var ds = new DataSet(); adapter.Fill(ds); general gn = new general(); var data = gn.ConvertDatasetToListJson(ds); if (data == null) { return("{\"result\":\"OK\",\"data\":\"[{\"status\":[]\"}]}"); } ; var json = gn.ConvertListToJson(data); var strResult = "{\"result\":\"OK\",\"data\":" + json + "}"; return(strResult); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } finally { if (cmd != null) { cmd.Dispose(); } if (adapter != null) { adapter.Dispose(); } if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } } }
// GET api/ExcuteOracle public IEnumerable <string> Get() { try { OracleConnection conn = null; OracleCommand cmd = null; OracleDataAdapter adapter = null; try { string connectOracle = ConfigurationManager.ConnectionStrings["ConnectOracle"].ConnectionString; conn = new OracleConnection(connectOracle); conn.Open(); cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT 'OK' OK FROM DUAL"; cmd.CommandType = CommandType.Text; cmd.BindByName = true; adapter = new OracleDataAdapter(cmd); var ds = new DataSet(); adapter.Fill(ds); general gn = new general(); var data = gn.ConvertDatasetToListJson(ds); if (data == null) { return new string[] { "ok 1", "1" } } ; var json = gn.ConvertListToJson(data); var strResult = "{\"result\":\"OK\",\"data\":" + json + "}"; return(new string[] { "ok 2", json }); } catch (Exception ex) { return(new string[] { "ERROR 3", ex.Message }); } finally { if (cmd != null) { cmd.Dispose(); } if (adapter != null) { adapter.Dispose(); } if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); } } return(new string[] { "value1", "value2" }); } catch (Exception ex) { return(new string[] { "errror 4 ", ex.Message }); } }
// POST: api/BulkCopySqlRenameCol public string Post(paraBulkTableSqlRename value) { try { general gn = new general(); var json = ""; var dicConfig = gn.ConfigConvertToDicConfig(value.config); if (dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } var table = JObject.Parse(value.table); if (table == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } gnSqlNomal gns = new gnSqlNomal(); var para = gns.convertParaToDic(value.para); DataTable dt = new DataTable("dt"); foreach (var val in table) { dt = gn.ConvertJsonToDataTable(val.Value.ToString(), val.Key); break; } // thay doi ten cot for (var c = 0; c < dt.Columns.Count; c++) { dt.Columns[c].ColumnName = "Col" + c; } var nextCol = dt.Columns.Count; // ADD THEM COT RONG VAO BANG. CHO DU 30 COT for (var j = nextCol; j < 50; j++) { try { DataColumn myColumn = new DataColumn(); myColumn.Caption = "Col" + j; myColumn.ColumnName = "Col" + j; myColumn.DefaultValue = ""; dt.Columns.Add(myColumn); } catch (Exception ex) { } } gnSql sql = new gnSql(); json = sql.BulkCopyToSqlNoLower(dt, dicConfig, para); return(json); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
public virtual ActionResult Download_MCF_Firmware(string fileName) { try { general gn = new general(); var dicAppSet = gn.ReadAppseting(); string fullPath = dicAppSet["mcf_path_firmware"] + fileName; return(File(fullPath, "application/text", fileName)); } catch { return(null); } }
// GET api/values public IEnumerable <string> Get() { general gn = new general(); dicAppSet = gn.ReadAppseting(); Db_Access ac = new Db_Access(); var check = ac.checkRequertLienTuc(HttpContext.Current, dicAppSet, "test", "test"); return(new string[] { "value1", (!check ? "Không được thực hiện lệnh liên tục trong " + dicAppSet["time_requestlientuc"] + " ms":"ok") }); }
// GET api/excel/5 public string Get(string id) { try { if (id == "") { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại userid\"}]}"); } var user = id; general gn = new general(); dicAppSet = gn.ReadAppseting(); var lst = JObject.Parse(_dicPara_exnom["StrColumnNames" + user]).SelectToken("kq").ToString(); var LstColumnNames = JsonConvert.DeserializeObject <List <ListColumnExport> >(lst); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } var lstPara = gn.ParaConvertListPara(_dicPara_exnom["StrPara" + user]); var dicConfig = gn.ConfigConvertToDicConfig(_dicPara_exnom["StrConfig" + user]); if (lstPara == null && dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } _dicPara_exnom.Remove("StrPara" + user); _dicPara_exnom.Remove("StrConfig" + user); _dicPara_exnom.Remove("StrColumnNames" + user); gnOracle orl = new gnOracle(); gnExcel exx = new gnExcel(); // var dtPara = orl.DecodeProceduePara(lstPara, dicConfigOk, dicAppSet); var dtPara = orl.DecodeProceduePara(lstPara, dicConfig, dicAppSet); var lstPrOrl = orl.dicParaToOraclePara(dtPara == null || dtPara.Tables.Count == 0 ? null : dtPara.Tables[0], lstPara); var ds = orl.ExcuteReturnDataSet(dicConfig["namesql"], (lstPrOrl == null ?null: lstPrOrl), CommandType.StoredProcedure, dicAppSet[dicConfig["connstr"].ToLower()]); if (ds == null || ds.Tables.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Không có dữ liệu xuất excel\"}]}"); } for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ds.Tables[0].Columns[i].ColumnName = ds.Tables[0].Columns[i].ColumnName.ToLower(); } exx.ExporttoExcel(new List <string>(), ds.Tables[0], LstColumnNames, dicConfig.ContainsKey("namefile") ? dicConfig["namefile"] : "" + DateTime.Now.ToString("dd-MM-yyyy"), 1, false, true); return(""); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// POST: api/TCP_OverServiceTcp public string Post(classTcp value) { try { gnSqlNomal gn = new gnSqlNomal(); general gns = new general(); var dicAppSet = gns.ReadAppseting(); if (value == null || value.config == null) { return(null); } var config = gn.convertConfigToDic(value.config); var para = gn.convertParaToDic(value.para); var result = ""; if (para["type"].ToLower() == "checkconnect" || para["type"].ToLower() == "receive") { var pathReceive = dicAppSet["pathfoldertcpreceive"] + config["namefile"]; if (File.Exists(pathReceive)) { var resultByte = File.ReadAllText(pathReceive).Replace("\r\n", "-0D-0A-"); byte[] data = Array.ConvertAll <string, byte>(resultByte.Substring(0, resultByte.Length - 1).Split('-'), s => Convert.ToByte(s, 16)); result = System.Text.ASCIIEncoding.ASCII.GetString(data); File.Delete(pathReceive); } else { return(""); } } else { var str = ""; foreach (var val in para) { str += val.Value + "\r\n"; } File.WriteAllText(dicAppSet["pathfoldertcpsend"] + config["namefile"], str); } return(result); } catch (Exception ex) { return(ex.Message); } }
// GET api/ExcelExportOracle/5 public string Get(string idrandom) { general gn = new general(); var dicAppSet = gn.ReadAppseting(); var lst = JObject.Parse(_dicPara_exoracle["StrColumnNames" + idrandom]).SelectToken("kq").ToString(); var LstColumnNames = JsonConvert.DeserializeObject <List <ListColumnExport> >(lst); // lay du lieu gnOracle or = new gnOracle(); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } var dicPara = gn.ParaConvertDicPara(_dicPara_exoracle["StrPara" + idrandom]); var dicConfig = gn.ConfigConvertToDicConfig(_dicPara_exoracle["StrConfig" + idrandom]); _dicPara_exoracle.Remove("StrPara" + idrandom); _dicPara_exoracle.Remove("StrConfig" + idrandom); _dicPara_exoracle.Remove("StrColumnNames" + idrandom); if (dicPara == null && dicConfig == null) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại định dạng json đầu vào\"}]}"); } var dsParaOnSql = or.DecodeProceduePara_New(dicConfig, dicAppSet); var paraOk = or.dicParaToOraclePara_New(dsParaOnSql, dicPara); var ds = or.ExcuteReturnDataSet(dicConfig["namesql"], paraOk.ToList(), CommandType.StoredProcedure, dicAppSet[dicConfig["connstr"].ToLower()]); if (ds == null || ds.Tables.Count == 0) { return(""); } var ds1 = gn.convertDatasetToLower(ds); gnExcel exx = new gnExcel(); var idtable = 0; if (dicConfig.ContainsKey("exporttable")) { idtable = Convert.ToInt32(dicConfig["exporttable"]); } exx.ExporttoExcel(new List <string>(), ds1.Tables[idtable], LstColumnNames, dicConfig.ContainsKey("namefile") ? dicConfig["namefile"] : "" + DateTime.Now.ToString("dd-MM-yyyy"), 1, false, true); return(""); }
// GET api/excelsqlexcute/5 public string Get(string id) { try { if (id == null || id == "undefind" || id == "") { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Kiểm tra lại userid\"}]}"); } var user = id; general gn = new general(); dicAppSet = gn.ReadAppseting(); var lst = JObject.Parse(_dicPara_exsql["StrColumnNames_SqlExcute" + user]).SelectToken("kq").ToString(); var LstColumnNames = JsonConvert.DeserializeObject <List <ListColumnExport> >(lst); if (dicAppSet == null || dicAppSet.Count == 0) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"Đọc appsetting lỗi\"}]}"); } gnSqlNomal gns = new gnSqlNomal(); var dicConfig = gns.convertConfigToDic(_dicPara_exsql["StrConfig_SqlExcute" + user]); var dicPara = gns.convertParaToDic(_dicPara_exsql["StrPara_SqlExcute" + user]); _dicPara_exsql.Remove("StrPara_SqlExcute" + user); _dicPara_exsql.Remove("StrConfig_SqlExcute" + user); _dicPara_exsql.Remove("StrColumnNames_SqlExcute" + user); gnSql sql = new gnSql(); gnExcel exx = new gnExcel(); var paraSql = gn.ConvertDicToSqlPara(dicPara); var ds = sql.DynamicSelectDataset(dicConfig["namesql"], (paraSql == null ?null: paraSql), CommandType.StoredProcedure, dicAppSet[dicConfig["connstr"].ToLower()]); if (ds == null || ds.Tables.Count == 0) { return("{\"result\":\"OK\",\"data\":[{\"status\":\"Không có dữ liệu xuất excel\"}]}"); } for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ds.Tables[0].Columns[i].ColumnName = ds.Tables[0].Columns[i].ColumnName.ToLower(); } exx.ExporttoExcel(new List <string>(), ds.Tables[0], LstColumnNames, dicConfig.ContainsKey("namefile") ? dicConfig["namefile"] : "" + DateTime.Now.ToString("dd-MM-yyyy"), 1, false, true); return(""); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// POST: api/LayDanhSachFileTrongThuMuc public string Post(DanhSachFile value) { try { general gns = new general(); gnSqlNomal gn = new gnSqlNomal(); var dicAppSet = gns.ReadAppseting(); var lst = new List <string>(); var folders = gns.GetAllFolder(dicAppSet["hddt_path_downloadfilechuaky_log"]); var para = gn.convertParaToDic(value.para); // neu la thang nam var namthangky = ""; var loai = ""; if (para.ContainsKey("namthangky")) { namthangky = para["namthangky"]; } if (para.ContainsKey("loai")) { loai = para["loai"]; } foreach (var fol in folders) { var files = Directory.GetFiles(fol); foreach (var file in files) { if (namthangky != "" && file.ToLower().IndexOf(loai) >= 0 && file.ToLower().IndexOf(namthangky) >= 0) { var sp = file.Split('\\'); var name = sp[sp.Length - 1]; lst.Add(name); } else { var sp = file.Split('\\'); var name = sp[sp.Length - 1]; lst.Add(name); } } } var integers = Newtonsoft.Json.JsonConvert.SerializeObject(lst); return(integers); } catch (Exception ex) { return(ex.Message); } }
// GET: api/Check_PingServer public string Get() { gnSqlNomal sqln = new gnSqlNomal(); general gn = new general(); var dicAppSet = gn.ReadAppseting(); if (!dicAppSet.ContainsKey("pathcheckserver")) { return("{\"status\":\"Không chứa pathcheckserver\"}"); } var strfileInfo = File.ReadAllText(dicAppSet["pathcheckserver"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); return("{\"status\":\"OK\",\"istype\":\"PingServer\",\"servername\":\"" + dicFileInfo["servername"] + "\"}"); }
public string Post(ValueExcelSqlXcuteTable value) { try { general gn = new general(); dicAppSet = gn.ReadAppseting(); _dicPara_exsql1.Add("StrPara_SqlExcute" + value.userid, value.para); _dicPara_exsql1.Add("StrConfig_SqlExcute" + value.userid, value.config); _dicPara_exsql1.Add("StrColumnNames_SqlExcute" + value.userid, value.colum); _dicPara_exsql1.Add("StrTable_SqlExcute" + value.userid, value.table == null ? "" : value.table); return(""); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
public string Post(ValueExcel value) { try { general gn = new general(); dicAppSet = gn.ReadAppseting(); _dicPara_exnom.Add("StrPara" + value.userid, value.para); _dicPara_exnom.Add("StrConfig" + value.userid, value.config); _dicPara_exnom.Add("StrColumnNames" + value.userid, value.colum); return(""); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
public string Post(dataExcel value) { try { _dicPara_table = new Dictionary <string, string>(); general gn = new general(); dicAppSet = gn.ReadAppseting(); _dicPara_table.Add("StrTableData" + value.userid, value.para); _dicPara_table.Add("StrTableConfig" + value.userid, value.config); _dicPara_table.Add("StrTableColumnNames" + value.userid, value.colum); return(""); } catch (Exception ex) { return("{\"result\":\"ERROR\",\"data\":[{\"status\":\"" + ex.Message.Replace("\n", "") + "\"}]}"); } }
// GET: api/Check_CheckNotRepond public string Get() { gnSqlNomal sqln = new gnSqlNomal(); general gn = new general(); var dicAppSet = gn.ReadAppseting(); if (!dicAppSet.ContainsKey("pathcheckserver")) { return("{\"status\":\"Không chứa pathcheckserver\"}"); } var strfileInfo = File.ReadAllText(dicAppSet["pathcheckserver"]); var dicFileInfo = sqln.convertParaToDic(strfileInfo); var dicProcess = new Dictionary <string, string>(); foreach (Process p in Process.GetProcesses(".")) { try { var name = p.MainWindowTitle != "" ? p.MainWindowTitle : p.ProcessName; dicProcess.Add(name.ToLower(), p.Responding ? "Runing" : "NotRespond"); } catch { } } if (!dicFileInfo.ContainsKey("checklstnotrespond")) { return("{\"status\":\"Không chứa checklstnotrespond\"}"); } var lstCheck = dicFileInfo["checklstnotrespond"].Split(new string[] { "===" }, StringSplitOptions.None); var str = ""; foreach (var name in lstCheck) { if (dicProcess.ContainsKey(name.ToLower())) { str += "{\"name\":\"" + name + "\",\"status\":\"" + dicProcess[name.ToLower()] + "\",\"istype\":\"CheckNotRespond\",\"servername\":\"" + dicFileInfo["servername"] + "\"},"; } } var sum = str != "" ? str.Substring(0, str.Length - 1) : ""; return("[" + sum + "]"); }