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.
434 lines
17 KiB
C#
434 lines
17 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.DAL.MsCompanysDAL;
|
|
using DSWeb.MvcShipping.Models.MsCompanys;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using System.Collections.Generic;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Models;
|
|
using DSWeb.Attributes;
|
|
using DSWeb.SoftMng.DBUtility;
|
|
using DSWeb.SoftMng.BLL;
|
|
using DSWeb.SoftMng.Common;
|
|
using DSWeb.SoftMng.Model;
|
|
using DSWeb.Areas.MvcShipping.Comm;
|
|
using System.Web.Configuration;
|
|
using System.IO;
|
|
using System.Text;
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class MsCompanysController : Controller
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult MsCompanysAccountIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult MsCompanysDeptIndex()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
//
|
|
var dataList = MsCompanysDAL.GetDataList(strPath, strPhotoPath, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), 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 };
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetNoPicDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
//
|
|
var dataList = MsCompanysDAL.GetNoPicDataList(condition);
|
|
var list = dataList.ToList();
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetDataListStr(string sort, string condition)
|
|
{
|
|
var dataListStr = MsCompanysDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
//
|
|
MsCompanysEntity head = null;
|
|
head = MsCompanysDAL.GetData(strPath, strPhotoPath, condition);
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
public ContentResult GetNoPicData(string condition)
|
|
{
|
|
//
|
|
MsCompanysEntity head = null;
|
|
head = MsCompanysDAL.GetNoPicData(condition);
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult SaveEtdCloseDay(string companyid,string CLOSEETDDAY)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
|
if (CLOSEETDDAY != "")
|
|
{
|
|
var blUpSQL = " update company set CLOSEETDDAY='"+CLOSEETDDAY+"' WHERE GID='"+companyid+"' ";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
else {
|
|
var blUpSQL = " update company set CLOSEETDDAY=NULL WHERE GID='" + companyid + "' ";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "设置成功"});
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
[HttpPost]
|
|
public ContentResult Save(string opstatus, string data)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
var headData = JsonConvert.Deserialize<MsCompanysEntity>(data);
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
//
|
|
#region 默认赋值
|
|
//headData.LOGO 徽标 Image 16
|
|
headData.ISDELETED = false;
|
|
//headData.ISDISABLE = false;//是否被禁用
|
|
headData.PARENTID = "";
|
|
headData.GPSUser = "";
|
|
headData.GPSPassWord = "";
|
|
//
|
|
headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
|
|
headData.CREATETIME = DateTime.Now;//创建时间
|
|
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人
|
|
headData.MODIFIEDTIME = DateTime.Now;//最后一次操作时间
|
|
#endregion
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
headData.GID = "Com" + Guid.NewGuid().ToString().Replace("-", "");//惟一编号 varchar(36)
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
|
|
#region LOGO_微标
|
|
var jsonRespose1 = new JsonResponse { Success = false, Message = "" };
|
|
headData.LOGO = null;
|
|
if (Request.Files.Count > 0)
|
|
{
|
|
var UpFile = Request.Files["upload"];
|
|
if (UpFile != null)
|
|
{
|
|
var FileLength = UpFile.ContentLength;//获取上传文件的字节大小
|
|
if (FileLength > 0)
|
|
{
|
|
Byte[] FileByte = new Byte[FileLength]; //图象文件储存到数组
|
|
Stream ObjectStream = UpFile.InputStream;//建立数据流对像,获取一个 Stream 对象,该对象指向一个上载文件,以准备读取该文件的内容。
|
|
ObjectStream.Read(FileByte, 0, FileLength); //读取图象文件数据
|
|
headData.LOGO = FileByte;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
if (isPost)
|
|
{
|
|
string strPath = "../../images/logo/noImage.gif";
|
|
string strPhotoPath = Server.MapPath(strPath);
|
|
var modb = new ModelObjectDB();
|
|
//DBResult result = modb.Save(headData);
|
|
DBResult result = MsCompanysDAL.Save(headData);
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsCompanysDAL.GetData(strPath, strPhotoPath, "GID='" + headData.GID + "'")
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
var jsonRespose = new JsonResponse { Success = false, Message =errorstr };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
#region 删除
|
|
public ContentResult Delete(string data)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
var head = JsonConvert.Deserialize<MsCompanysEntity>(data);
|
|
var modb = new ModelObjectDB();
|
|
//DBResult result = modb.Delete(head);
|
|
DBResult result = MsCompanysDAL.Delete(head);
|
|
if (result.Success == true)
|
|
{
|
|
DBResult result2 = MsCompanysDAL.setLog(head, Convert.ToString(Session["USERID"]));
|
|
}
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
#endregion
|
|
|
|
#region 注册
|
|
public ContentResult RefReg()
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
|
|
sys_secCompanyBLL cbll = new sys_secCompanyBLL();
|
|
sys_secCompany cmodel = cbll.GetModelList("").FirstOrDefault(); //获取客户端实例
|
|
|
|
DBResult result = new DBResult();
|
|
try
|
|
{
|
|
//同步公司配置表
|
|
|
|
|
|
var smodel = getServerCompanyREG(cmodel.GID); //服务端实例
|
|
if (smodel.OperTime > cmodel.OperTime) //服务端最后更新时间大于客户端更新时间则更新
|
|
cbll.Update(smodel);
|
|
|
|
//同步模块配置表(本公司)
|
|
sys_secModuleBLL mbll = new sys_secModuleBLL();
|
|
|
|
var list1 = getServerModelREG(cmodel.GID); //获取服务端数据
|
|
foreach (var item in list1)
|
|
{
|
|
var cmodel1 = mbll.GetModel(item.GID);
|
|
if (cmodel1 != null)
|
|
{
|
|
if (item.OperTime > cmodel1.OperTime) //服务端最后更新时间大于客户端更新时间则更新
|
|
mbll.Update(item);
|
|
}
|
|
else
|
|
mbll.Add(item);
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "刷新成功!";
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "刷新过程出错:"+ex.Message;
|
|
|
|
// Page.ClientScript.RegisterStartupScript(this.GetType(), "key0",
|
|
//"<script>alert('无法连接验证服务器,无法登录!');history.back();</script>");
|
|
// return;
|
|
|
|
//使用内网无法连接服务器地址会出现异常
|
|
//do something...
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
protected sys_secCompany getServerCompanyREG(string GID)
|
|
{
|
|
try
|
|
{
|
|
var IP = getConfigIP();
|
|
|
|
var dic = new Dictionary<string, string>();
|
|
dic.Add("GID", SoftMng.Common.Common.string_Encrypt(GID, ""));
|
|
var rtn = WebRequestHelper.DoPost(IP + "GetSecCompany", dic, 5000);
|
|
|
|
DBResult r = Newtonsoft.Json.JsonConvert.DeserializeObject<DBResult>(rtn);
|
|
|
|
if (r.Success)
|
|
{
|
|
sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(r.Data.ToString());
|
|
return companyREG;
|
|
}
|
|
else
|
|
{
|
|
return new sys_secCompany();
|
|
}
|
|
//sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(rtn);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//var r = new sys_secCompany();
|
|
//r.CompanySecretKey = e.Message;
|
|
//return new sys_secCompany();
|
|
try
|
|
{
|
|
sys_secCompanyBLL cbll = new sys_secCompanyBLL();
|
|
StringBuilder where = new StringBuilder();
|
|
where.Append("select * from sys_secCompany where GID ='" + GID + "'");
|
|
var ds = DbHelperServerSQL.Query(where.ToString());
|
|
var smodel = cbll.DataRowToModel(ds.Tables[0].Rows[0]); //服务端实例
|
|
return smodel;
|
|
|
|
}
|
|
catch
|
|
{
|
|
return new sys_secCompany();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
protected List<sys_secModule> getServerModelREG(string GID)
|
|
{
|
|
try
|
|
{
|
|
var IP = getConfigIP();
|
|
|
|
var dic = new Dictionary<string, string>();
|
|
dic.Add("GID", SoftMng.Common.Common.string_Encrypt(GID, ""));
|
|
var rtn = WebRequestHelper.DoPost(IP + "GetSecModel", dic, 5000);
|
|
|
|
DBResult r = Newtonsoft.Json.JsonConvert.DeserializeObject<DBResult>(rtn);
|
|
|
|
if (r.Success)
|
|
{
|
|
List<sys_secModule> ModelREGList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<sys_secModule>>(r.Data.ToString());
|
|
return ModelREGList;
|
|
}
|
|
else
|
|
{
|
|
return new List<sys_secModule>();
|
|
}
|
|
//sys_secCompany companyREG = Newtonsoft.Json.JsonConvert.DeserializeObject<sys_secCompany>(rtn);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
try
|
|
{
|
|
sys_secModuleBLL mbll = new sys_secModuleBLL();
|
|
StringBuilder where = new StringBuilder();
|
|
where.Append("select * from sys_secModule where PID ='" + GID + "'");
|
|
var ds = DbHelperServerSQL.Query(where.ToString());
|
|
if (ds.Tables.Count > 0)
|
|
{
|
|
var modelList = mbll.DataTableToList(ds.Tables[0]); //服务端实例
|
|
return modelList;
|
|
}
|
|
else
|
|
{
|
|
return new List<sys_secModule>();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return new List<sys_secModule>();
|
|
}
|
|
|
|
//var r = new sys_secCompany();
|
|
//r.CompanySecretKey = e.Message;
|
|
//return new List<sys_secModule>();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
private string getConfigIP()
|
|
{
|
|
|
|
string strConn = "";
|
|
|
|
try
|
|
{
|
|
strConn = WebConfigurationManager.AppSettings["RegServer"].ToString();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
strConn = "";
|
|
}
|
|
var IP = "";
|
|
if (string.IsNullOrWhiteSpace(strConn))
|
|
{
|
|
try
|
|
{
|
|
strConn = System.Configuration.ConfigurationManager.ConnectionStrings["DongShengDBServer"].ConnectionString;
|
|
var strlist = strConn.Split(';');
|
|
var serverStr = strlist[0];
|
|
int startIndex = serverStr.IndexOf("=");//开始位置
|
|
IP = serverStr.Substring(startIndex + 1, serverStr.Length - startIndex - 1);//
|
|
if (IP.IndexOf(":") > 0) IP = IP.Substring(0, IP.IndexOf(":"));
|
|
}
|
|
catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(IP)) IP = "47.104.102.13";
|
|
strConn = "http://" + IP + ":8081";
|
|
}
|
|
|
|
var result = strConn + "/Dispatch/RegPort/";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
//
|
|
}
|
|
}
|
|
|