You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/SoftMng/Controllers/MsSoftUpGradeController.cs

313 lines
11 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.SoftMng.Models.MsSoftUpGrade;
using DSWeb.SoftMng.DAL.SoftUpGrade;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using System.IO;
using System.Data;
using System.Data.OleDb;
using DSWeb.EntityDA;
using DSWeb.DataAccess;
namespace DSWeb.SoftMng.Controllers
{
[JsonRequestBehavior]
public class MsSoftUpGradeController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult SoftUpdate()
{
return View();
}
public ActionResult SoftUpdateEdit()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsSoftUpGradeDAL.GetDataList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetUpDateLogList(int start, int limit, string sort, string condition)
{
var dataList = MsSoftUpGradeDAL.GetUpDateLogList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
sys_update_sql head = null;
if (handle == "edit")
{
var list = MsSoftUpGradeDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new sys_update_sql();
head.UPSTATUS = "新增";
head.INPUTBY = Convert.ToString(Session["USERID"]);
head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]);
var sqlver="7."+DateTime.Now.ToString("yy.MMdd");
head.SQLVER = sqlver;
head.SORT = MsSoftUpGradeDAL.GetMaxSort("SQLVER='"+sqlver+"'").ToString();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string body)
{
var headData = JsonConvert.Deserialize<sys_update_sql>(data);
var bodyList = JsonConvert.Deserialize<List<sys_update_sql_table>>(body);
var errorstr = "";
var isPost = true;
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.INPUTBY = Convert.ToString(Session["USERID"]);
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.UPSTATUS = "新增";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var GID = headData.GID;
if (isPost)
{
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success == true)
{
result = MsSoftUpGradeDAL.Savesqltable(bodyList, GID, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsSoftUpGradeDAL.GetData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<List<sys_update_sql>>(data);
DBResult result = MsSoftUpGradeDAL.Deletesys_update_sql(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SubmitAudit(string bill,string type)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (type == "2")
{
string blUpSQL = "update sys_update_sql set UPSTATUS='提交审核' where GID='" + bill + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else if (type == "1")
{
string blUpSQL = "update sys_update_sql set UPSTATUS='新增' where GID='" + bill + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = MsSoftUpGradeDAL.GetData("GID='" + bill + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AuditSql(string bill, string type)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (type == "0")
{
string blUpSQL = "update sys_update_sql set UPSTATUS='审核通过',AUDITBY='" + Convert.ToString(Session["USERID"]) + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID='" + bill + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else if (type == "3")
{
string blUpSQL = "update sys_update_sql set UPSTATUS='驳回提交',AUDITBY='" + Convert.ToString(Session["USERID"]) + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID='" + bill + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = MsSoftUpGradeDAL.GetData("GID='" + bill + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetSvrVer()
{
sys_update_sql head = null;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var strSQLVER = T_ALL_DA.GetOtStrSQL("Server=115.29.108.236,1433;Database=ShippingWeb_UPDATE;User ID=sa;Password=Ds140101;Connect Timeout=18000;", "SQLVER", "select top 1 SQLVER from sys_update_sql order by SQLVER DESC,SORT DESC");
head = new sys_update_sql();
head.SQLVER = strSQLVER;
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetUpDateData(string sqlver,string sort)
{
var connectstr = "Server=115.29.108.236,1433;Database=ShippingWeb_UPDATE;User ID=sa;Password=Ds140101;Connect Timeout=18000;";
var dataList = MsSoftUpGradeDAL.GetUpDateData(connectstr, sqlver,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult ExecUpSql(string data)
{
var headDataList = JsonConvert.Deserialize <List<sys_update_sql>>(data);
bool zas = false;
var errostr = "";
var headData = headDataList[0];
try
{
zas = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, headData.SQLTEXT);
}
catch (Exception execError2)
{
errostr = execError2.ToString();
}
if (zas == true)
{
MsSoftUpGradeDAL.SaveSysSoft(headData,"成功执行","", Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success =true, Message ="执行成功!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
MsSoftUpGradeDAL.SaveSysSoft(headData, "执行出错", errostr, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = false, Message = errostr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 相关表
public ContentResult GetSqlTableList(string condition, string sort)
{
var dataList = MsSoftUpGradeDAL.GetSqlTableList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveSqlTable(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<sys_update_sql_table>>(body);
DBResult result = MsSoftUpGradeDAL.Savesqltable(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteSqlTable(string data)
{
var headData = JsonConvert.Deserialize<List<sys_update_sql_table>>(data);
DBResult result = MsSoftUpGradeDAL.Deletesqltable(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 参照部分
#endregion
}
}