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/CommMng/DAL/PublicInterfaceDAL.cs

185 lines
4.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.Entity.Migrations;
using System.Data.Entity.Validation;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security.Permissions;
using System.ServiceModel.Configuration;
using System.Text;
using System.Web;
using System.Windows.Forms;
using DSWeb.Areas.CommMng.Controllers;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
using DSWeb.Common.DB;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.MvcShipping.Controllers;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Newtonsoft.Json.Linq;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace DSWeb.Areas.CommMng.PublicInterfaceDAL
{
public class InterfaceResult
{
public string errCode { get; set; }
public string errMsg { get; set; }
public InterfaceResult() { }
public InterfaceResult(DBResult dbresult)
{
if (dbresult.Success)
{
errCode = "0";
}
else
{
errCode = "1";
}
errMsg = dbresult.Message + ";Data:" + JsonConvert.Serialize(dbresult.Data);
}
}
public class InterfaceParam
{
public Interface_Header header { get; set; }
public object body { get; set; }
public t_PublicInterface_Log_md getsaverec()
{
var result = new t_PublicInterface_Log_md();
try
{
result.GID = Guid.NewGuid().ToString();
result.Param = body.ToString();
result.PORTNAME = header.serviceCode;
result.CreateTime = DateTime.Now;
}
catch (Exception e) {
}
return result;
}
public void Save()
{
var saverec = getsaverec();
if (!string.IsNullOrWhiteSpace(saverec.Param) && !string.IsNullOrWhiteSpace(saverec.PORTNAME))
{
var cdc = new CommonDataContext();
cdc.t_PublicInterface_Log.Add(saverec);
cdc.SaveChanges();
}
}
}
public class Interface_Header
{
public string serviceCode { get; set; }
}
public static class InterfaceLog {
public static void Save(string PORTNAME,object c) {
var saverec = getsaverec(PORTNAME,c);
if (!string.IsNullOrWhiteSpace(saverec.Param) && !string.IsNullOrWhiteSpace(saverec.PORTNAME))
{
var cdc = new CommonDataContext();
cdc.t_PublicInterface_Log.Add(saverec);
cdc.SaveChanges();
}
}
private static t_PublicInterface_Log_md getsaverec(string PORTNAME, object c)
{
var result = new t_PublicInterface_Log_md();
try
{
result.GID = Guid.NewGuid().ToString();
result.PORTNAME= PORTNAME;
result.Param = JsonConvert.Serialize(c);
result.CreateTime = DateTime.Now;
}
catch (Exception e)
{
}
return result;
}
}
public class InterfaceBase
{
public InterfaceBase() { }
public virtual InterfaceResult DoSet(JObject paramObject)
{
return new InterfaceResult();
}
//public static void SaveParam(InterfaceParam param) {
// param.Save();
//}
}
#region 全泰 账单拆分
/// <summary>
/// 全泰 账单拆分
/// </summary>
public class
{
public DBResult DoSet(object Objectparam)
{
var paramstr = Objectparam.ToString();
//paramstr = paramstr.Remove(0, 1);
//paramstr = paramstr.Remove(paramstr.Length - 1, 1);
var param = JsonConvert.Deserialize<List<_Bill>>(paramstr);
var result = new DBResult();
try
{
InterfaceLog.Save("全泰账单解析", param);
result.OK();
}
catch (Exception ex)
{
//var newerror = new t_sys_soft_error_md();
//newerror.针对版本 = 0;
//newerror.升级日期 = DateTime.Now;
//newerror.升级人 = "管理员";
//newerror.执行文件 = $"[{ex.Message}]" + errorstr;
//var ds62 = new DS6DataContext();
//ds62.t_sys_soft_error.Add(newerror);
//ds62.SaveChanges();
InterfaceLog.Save("全泰账单_Error", ex);
result.SetErrorInfo(JsonConvert.Serialize(ex));
return result;
}
return result;
}
}
#endregion
}