|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
|
|
|
using DSWeb.TruckMng.Helper;
|
|
|
|
|
using WebSqlHelper;
|
|
|
|
|
using System.Web.Configuration;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.CommMng.Controllers
|
|
|
|
|
{
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class PrintController : Controller
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// GET: /CommMng/Print/
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ValidateInput(false)]
|
|
|
|
|
public ContentResult GetPrintInfo(string type, string sql1, string sql2, string sql3, string sql4, string sql5, string sql6, string billno = "", string RpID = "", string RptMode = "",string bsno="")
|
|
|
|
|
{
|
|
|
|
|
//var companyId = string.Empty;
|
|
|
|
|
//var userId =Convert.ToString(CookieConfig.GetCookie_UserId(Request));
|
|
|
|
|
int iTempStatus = 0;
|
|
|
|
|
|
|
|
|
|
//var strResult = string.Empty;
|
|
|
|
|
////先获取用户所在的公司信息GID
|
|
|
|
|
//CompanyEntity companyEntity = new CompanyEntity();
|
|
|
|
|
//CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
|
|
|
|
|
//companyEntity = companyDA.GetCompanyByUserID(userId);
|
|
|
|
|
|
|
|
|
|
//if (companyEntity.GID != null)
|
|
|
|
|
//{
|
|
|
|
|
// companyId = companyEntity.GID;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var userId = Convert.ToString(Session["USERID"]);
|
|
|
|
|
var companyId = Convert.ToString(CookieConfig.GetCookie_CompanyId(Request));
|
|
|
|
|
|
|
|
|
|
ReportDBSourceDA reportDbSourceDa = new ReportDBSourceDA();
|
|
|
|
|
ReportDBSourceEntity reportDBSourceEntity = new ReportDBSourceEntity();
|
|
|
|
|
reportDBSourceEntity = reportDbSourceDa.GetReportDBSourceByUserIDAndType(userId, type);
|
|
|
|
|
|
|
|
|
|
//业务数据集,共6个
|
|
|
|
|
reportDBSourceEntity.SqlString_1 = sql1;
|
|
|
|
|
reportDBSourceEntity.SqlString_2 = sql2;
|
|
|
|
|
reportDBSourceEntity.SqlString_3 = sql3;
|
|
|
|
|
reportDBSourceEntity.SqlString_4 = sql4;
|
|
|
|
|
reportDBSourceEntity.SqlString_5 = sql5;
|
|
|
|
|
reportDBSourceEntity.SqlString_6 = sql6;
|
|
|
|
|
reportDBSourceEntity.Description = billno;
|
|
|
|
|
reportDBSourceEntity.Name = bsno;
|
|
|
|
|
//如果有相似的值则直接获取
|
|
|
|
|
if (reportDBSourceEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//以下每一个打印都是一样的,可不改
|
|
|
|
|
reportDBSourceEntity.SqlString_7 = "SELECT [user].USERNAME,[user].CODENAME,[user].PASSWORD,[user].SHOWNAME,[user].ENROLLTIME,[user].CREATEUSER,[user].MODIFIEDUSER, [user].MODIFIEDTIME, [user].ISDELETED, [user].ISDISABLE, user_baseinfo.GID,user_baseinfo.USERID,user_baseinfo.COMPANYNAME, user_baseinfo.DEPTNAME, user_baseinfo.OFFICEPHONE, user_baseinfo.HOMEPHONE, user_baseinfo.MOBILE, user_baseinfo.FAX, user_baseinfo.EMAIL1, user_baseinfo.EMAIL2, user_baseinfo.HOMEADDRESS, user_baseinfo.REMARK, user_baseinfo.EMERGUSER, user_baseinfo.EMERGPHONE,user_baseinfo.EMERGEMAIL, user_baseinfo.POSTCODE, user_baseinfo.QQ, user_baseinfo.MSN, user_baseinfo.FINANCESOFTCODE FROM [user] INNER JOIN user_baseinfo ON [user].GID = user_baseinfo.USERID where user_baseinfo.USERID='" + userId + "'";//登录人的信息(每一个打印都是一样的,可不改)
|
|
|
|
|
reportDBSourceEntity.SqlString_8 = " SELECT * FROM [company] WHERE GID = '" + companyId + "'";//登录人的企业信息(每一个打印都是一样的,可不改)
|
|
|
|
|
|
|
|
|
|
iTempStatus = reportDbSourceDa.UpdateReportSql(reportDBSourceEntity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
reportDBSourceEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
reportDBSourceEntity.ReportID = "";
|
|
|
|
|
reportDBSourceEntity.Name = bsno;
|
|
|
|
|
reportDBSourceEntity.Description = billno;
|
|
|
|
|
reportDBSourceEntity.Type = type;
|
|
|
|
|
reportDBSourceEntity.CreateUser = userId;
|
|
|
|
|
reportDBSourceEntity.UserID = userId;
|
|
|
|
|
|
|
|
|
|
reportDBSourceEntity.SqlString_7 = "SELECT [user].USERNAME,[user].CODENAME,[user].PASSWORD,[user].SHOWNAME,[user].ENROLLTIME,[user].CREATEUSER,[user].MODIFIEDUSER, [user].MODIFIEDTIME, [user].ISDELETED, [user].ISDISABLE, user_baseinfo.GID,user_baseinfo.USERID,user_baseinfo.COMPANYNAME, user_baseinfo.DEPTNAME, user_baseinfo.OFFICEPHONE, user_baseinfo.HOMEPHONE, user_baseinfo.MOBILE, user_baseinfo.FAX, user_baseinfo.EMAIL1, user_baseinfo.EMAIL2, user_baseinfo.HOMEADDRESS, user_baseinfo.REMARK, user_baseinfo.EMERGUSER, user_baseinfo.EMERGPHONE,user_baseinfo.EMERGEMAIL, user_baseinfo.POSTCODE, user_baseinfo.QQ, user_baseinfo.MSN, user_baseinfo.FINANCESOFTCODE FROM [user] INNER JOIN user_baseinfo ON [user].GID = user_baseinfo.USERID where user_baseinfo.USERID='" + userId + "'";
|
|
|
|
|
reportDBSourceEntity.SqlString_8 = " SELECT * FROM [company] WHERE GID = '" + companyId + "'";
|
|
|
|
|
|
|
|
|
|
iTempStatus = reportDbSourceDa.InsertReportDBSource(reportDBSourceEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iTempStatus == 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var sqlstr = SqlHelper.ConnectionStringLocalTransaction;
|
|
|
|
|
var RemoteServer = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RemoteServer = WebConfigurationManager.AppSettings["RemoteServer"].ToString();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = false, Message = "取得打印数据失败" });
|
|
|
|
|
if (RemoteServer == "")
|
|
|
|
|
{
|
|
|
|
|
json = JsonConvert.Serialize(
|
|
|
|
|
// new { Success = true, Message = "查询成功", CompanyID = companyId, DbSourceID = reportDBSourceEntity.GID, UserId = userId, PrServer = RemoteServer, dbStr = sqlstr });
|
|
|
|
|
new { Success = true, Message = "查询成功", CompanyID = companyId, DbSourceID = reportDBSourceEntity.GID, UserId = userId });
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = true, Message = "查询成功", CompanyID = companyId, DbSourceID = reportDBSourceEntity.GID, UserId = userId, PrServer = RemoteServer, dbStr = sqlstr, RpID = RpID, RptMode = RptMode });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
|
|
new { Success = false, Message = "取得打印数据失败"});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ContentResult UploadMailFile()
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Files["LoadFile"];
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MailFile");
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
|
var bsno = Request.Form["bsno"];
|
|
|
|
|
|
|
|
|
|
var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
|
|
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
}
|
|
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件出错";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
filename = Path.GetFileName(filename);
|
|
|
|
|
var urlfilename = "../../UploadFiles/MailFile/" + filename;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功",data= urlfilename });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件出错";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|