我的代码检查数据库中的更改,然后通过 Web 服务向客户端发送更新。
我让向客户端发送消息的部分工作正常,因为调用检查数据库中的更改。现在我已经添加了检查数据库更改的部分,我收到以下错误。
在调试我的代码时,错误指向代码最底部的异常,所以我不知道错误来自哪里,也无法修复它。
任何建议将不胜感激
SendInvUpdate.InvServices.UpdateRatePackagesRequest ur = new SendInvUpdate.InvServices.UpdateRatePackagesRequest();
SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse or = new SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse();
protected void Page_Load(object sender, EventArgs e)
{
try
{
string connStr = ConfigurationManager.ConnectionStrings["bb"].ConnectionString;
SqlConnection Con = new SqlConnection(connStr);
Con.Open();
SqlCommand cmd = new SqlCommand("invpush_PollForAvailableChanges", Con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter NewSysChangeVersionParam = new SqlParameter("@NewSysChangeVersion", SqlDbType.Int);
NewSysChangeVersionParam.Value = (object)NewSysChangeVersionParam ?? DBNull.Value;
NewSysChangeVersionParam.Direction = ParameterDirection.InputOutput;
NewSysChangeVersionParam.SqlDbType = SqlDbType.BigInt;
SqlDataReader sdr = cmd.ExecuteReader();
InventoryPushSubscriptionRecord rec = new InventoryPushSubscriptionRecord();
while (sdr.Read())
{
rec.InventoryPushSubId = sdr.GetInt32(0);
rec.CMName = sdr.GetString(1);
rec.NotifUrl = sdr.GetString(2);
rec.Options = sdr.GetString(3);
rec.LastSysChangeVersion = sdr.IsDBNull(4)?(long?)null:sdr.GetInt32(4);
}
if(!sdr.NextResult()) throw new System.Exception("Expected Result set 1 for InventoryChangeRecord");
InventoryChangeRecord inrec = new InventoryChangeRecord();
while (sdr.Read())
{
inrec.InventoryPushSubId= sdr.GetInt32(0);
inrec.SysChangeVersion=sdr.IsDBNull(1)?(long?)null:sdr.GetInt32(1);
inrec.InvDate=sdr.GetDateTime(2);
inrec.ResId=sdr.GetInt32(3);
inrec.RoomType=sdr.GetString(4);
inrec.InvCount=sdr.GetInt32(5);
inrec.ResName=sdr.GetString(6);
}
sdr.Close();
sdr.Dispose();
if (NewSysChangeVersionParam != null)
{
int ResId;
Int64 ResoId;
ResortId = inrec.ResId;
SqlDataAdapter sda = new SqlDataAdapter("Select BID,RId from BBTest.bbtest.tblResMapping where BId=@ResId",Con);
SqlParameter resId = new SqlParameter("@ResId", ResId);
sda.SelectCommand.Parameters.Add(resId);
DataSet ds = new DataSet();
sda.Fill(ds, "tblresmapping");
if (ds.Tables[0].Rows.Count > 0)
{
ResoId = Convert.ToInt32(ds.Tables[0].Rows[0]["ResonlineId"]);
}
if (ds.Tables[0].Rows.Count != 0)
{
Int64 RatePackageId;
SqlDataAdapter sqlda = new SqlDataAdapter("Select BId,BBRoom,ResRatePackageID from tblResRatePackages where BID =@ResortId", Con);
SqlParameter resI = new SqlParameter("@RId", resId);
sqlda.SelectCommand.Parameters.Add(resI);
DataSet dt = new DataSet();
sqlda.Fill(dt, "tblResRatePackages");
if (dt.Tables[0].Rows.Count > 0)
{
RatePackageId = Convert.ToInt64(dt.Tables[0].Rows[0]["ResRatePackageID"]);
Int64 HID = ResId;
Int64 HRID = RatePackageId;
SendInvUpdate.InvServices.UpdateRatePackagesRequest request = new SendInvUpdate.InvServices.UpdateRatePackagesRequest();
request.HotelId = account.HotelId;
int avail = inrec.InvCount;
DateTime frodte = inrec.InvDate;
int NoofRatePackages = 3;
UpdateRatePackageRequest[] RatePackages = new UpdateRatePackageRequest[NoofRatePackages];
string res;
request.RatePackages = new UpdateRatePackageRequest[NoofRatePackages];
request.RatePackages = RatePackages;
for (int i = 0; i < NoofRatePackages; i++)
{
UpdateRatePackageRequest rp = new UpdateRatePackageRequest();
request.RatePackages[i] = rp;
rp.RatePackageId = HRID;
rp.Rates = new RateDetails[NoofRatePackages];
for (int j = 0; j < NoofRatePackages; j++)
{
RateDetails rd = new RateDetails();
rp.Rates[j] = rd;
rd.Availability = avail;
rd.AvailabilityApplicationType = SendInvUpdate.InvServices.AvailabilityApplicationType.SET;
rd.FromDate = frodte;
// rd.ToDate = todte;
}
}
SendInvUpdate.InvServices.InventoryServiceClient isc = new SendInvUpdate.InvServices.InventoryServiceClient();
or = isc.UpdateRatePackages(request);
res = or.Results.ToString();
}
}
}
}
catch (Exception ex)
{
throw (ex);
}
}
}
}