"Insert" と "Update" として webmethods があり、"DataParam" としてレコードの C# クラスがあります... AJAX 呼び出しを使用して行います。update メソッドは問題ありません。Ajax 呼び出しで Class を送信し、update を実行しましたが、Insert にエラー 500 が発生しました。それを乗り越えることができません。
これが私のクラスです:
public class DataParam
{
public string ATC1 { get; set; }
public string ATC2 { get; set; }
public string ATC3 { get; set; }
public string ATC4 { get; set; }
public string CurentlyProjectMark { get; set; }
public int Dosage { get; set; }
public string Dosage_Title { get; set; }
public string FirstMark { get; set; }
public int Form { get; set; }
public string Form_Title { get; set; }
public long Id { get; set; }
public Guid Key { get; set; }
public string LicensedTradeMark { get; set; }
public long Molecule { get; set; }
public string Molecule_Title { get; set; }
public string ProductName { get; set; }
public int ProjectCode { get; set; }
public string ProjectCode_Title { get; set; }
public DateTime RD_DataProtectionEndDate { get; set; }
public string RD_Description { get; set; }
public int RD_Document_Author { get; set; }
public DateTime RD_Document_CheckDate { get; set; }
public string RD_Document_CheckDescription { get; set; }
public DateTime RD_Document_ComingDate { get; set; }
public string RD_Document_ComingDescription { get; set; }
public int RD_Document_Controller { get; set; }
public DateTime RD_Document_DoneDate { get; set; }
public string RD_Document_DoneDescription { get; set; }
public DateTime RD_Document_RealesedDate { get; set; }
public string RD_Document_RealesedDescription { get; set; }
public int RD_Document_Status { get; set; }
public DateTime RD_Document_TargetDate { get; set; }
public string RD_Document_TargetDescription { get; set; }
public int RD_ProjectedFirm { get; set; }
public string RD_ProjectedName { get; set; }
public int RD_Responsible { get; set; }
public int RD_Status { get; set; }
public string Title { get; set; }
public string TradeMark { get; set; }
}
メソッドはこちら
[WebMethod(EnableSession = true)]
public static object Update(DataParam param = null)
{
try
{
CPI.RD.Product product = new CPI.RD.Product();
object objProduct = (CPI.RD.Product)product;
product = (CPI.RD.Product)CPI.RD.Helper.FillBussinesObject(param, ref objProduct);
CPI.RD.ProductManagement.Update(product);
return true;
}
catch (Exception ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
[WebMethod(EnableSession = true)]
public static object Insert2(DataParam param = null)
{
try
{
CPI.RD.Product product = new CPI.RD.Product();
object objProduct = (CPI.RD.Product)product;
product = (CPI.RD.Product)CPI.RD.Helper.FillBussinesObject(param, ref objProduct);
CPI.RD.ProductManagement.Insert(product);
return true;
}
catch (Exception ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
これがAJAX呼び出しです
var param = cpiGrid.getRecordForm(record);
// Check if it is new record
if ($(div).attr("data-new") == "true") {
url += "Insert2";
record = cpiGrid.getRecordForm(record);
data = JSON.stringify(record);
console.log("send to add: ", record, " data: ", data);
cpiGrid.getJSON(url, data, function () {
cpiGrid.listRecords();
$(".close-button").trigger("click");
});
}
詳細なエラー メッセージ:
{"Message":"Invalid web service call, missing value for parameter: \u0027param\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}