using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Forks.EnterpriseServices.JsonRpc;
|
|
using BWP.B3ClientService.BO;
|
|
using BWP.B3ClientService.RpcBO;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
using System.Web.Script.Serialization;
|
|
using TSingSoft.WebPluginFramework;
|
|
|
|
|
|
namespace BWP.B3ClientService.Rpcs.BillRpc
|
|
{
|
|
[Rpc]
|
|
public static class CarcassStateWeightRpc
|
|
{
|
|
static JavaScriptSerializer serializer = new JavaScriptSerializer();
|
|
|
|
[Rpc]
|
|
public static string GetCarcassStateWeightList(DateTime date, long? maxID)
|
|
{
|
|
var main = new JoinAlias(typeof(CarcassStateWeight));
|
|
var query = new DQueryDom(main);
|
|
query.Columns.Add(DQSelectColumn.Field("GradeAndWeight_ID"));
|
|
query.Columns.Add(DQSelectColumn.Field("Code"));
|
|
query.Columns.Add(DQSelectColumn.Field("CurrentWeight"));
|
|
query.Columns.Add(DQSelectColumn.Field("Nubmber"));
|
|
query.Columns.Add(DQSelectColumn.Field("Product_ID"));
|
|
query.Columns.Add(DQSelectColumn.Field("Product_Name"));
|
|
query.Columns.Add(DQSelectColumn.Field("State1Weight"));
|
|
query.Columns.Add(DQSelectColumn.Field("State2Weight"));
|
|
query.Columns.Add(DQSelectColumn.Field("State3Weight"));
|
|
query.Columns.Add(DQSelectColumn.Field("State4Weight"));
|
|
query.Columns.Add(DQSelectColumn.Field("State5Weight"));
|
|
query.Columns.Add(DQSelectColumn.Field("Time"));
|
|
query.Where.Conditions.Add(DQCondition.Between(DQExpression.Field(main, "Time"), date,
|
|
date + new TimeSpan(23, 59, 29)));
|
|
|
|
var list = new List<CarcassStateWeight>();
|
|
using (var session = Dmo.NewSession())
|
|
{
|
|
using (var reader = session.ExecuteReader(query))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var csw = new CarcassStateWeight();
|
|
csw.GradeAndWeight_ID = (long)reader[0];
|
|
csw.Code = (long?)reader[1];
|
|
csw.CurrentWeight = (decimal?)reader[2];
|
|
csw.Nubmber = (decimal?)reader[3];
|
|
csw.Product_ID = (long?)reader[4];
|
|
csw.Product_Name = (string)reader[5];
|
|
csw.State1Weight = (decimal?)reader[6];
|
|
csw.State2Weight = (decimal?)reader[7];
|
|
csw.State3Weight = (decimal?)reader[8];
|
|
csw.State4Weight = (decimal?)reader[9];
|
|
csw.State5Weight = (decimal?)reader[10];
|
|
csw.Time = (DateTime?)reader[11];
|
|
list.Add(csw);
|
|
// csw.CurrentState = (long)reader[0];
|
|
}
|
|
}
|
|
}
|
|
|
|
return serializer.Serialize(list);
|
|
}
|
|
|
|
|
|
[Rpc]
|
|
public static string GetGradeAndWeight_DetailByCode(long code)
|
|
{
|
|
var query = new DmoQuery(typeof(GradeAndWeight_Detail));
|
|
query.Where.Conditions.Add(DQCondition.EQ("ID", code));
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true));
|
|
return serializer.Serialize(query.EExecuteList());
|
|
}
|
|
|
|
[Rpc]
|
|
public static long UpdateOrInsertDetail(string json, bool fillTechnics)
|
|
{
|
|
json = json.ESerializeDateTime();
|
|
var entity = serializer.Deserialize<CarcassStateWeight>(json);
|
|
using (var session = Dmo.NewSession())
|
|
{
|
|
//if (entity.GradeAndWeight_ID == 0)
|
|
// session.Insert(entity);
|
|
//else
|
|
session.Insert(entity);
|
|
session.Commit();
|
|
return entity.GradeAndWeight_ID;
|
|
}
|
|
}
|
|
|
|
|
|
[Rpc]
|
|
public static int UpdateProduct(long id, long ProductID, string ProductName)
|
|
{
|
|
using (var session = Dmo.NewSession())
|
|
{
|
|
var update = new DQUpdateDom(typeof(CarcassStateWeight));
|
|
update.Where.Conditions.Add(DQCondition.EQ("GradeAndWeight_ID", id));
|
|
update.Columns.Add(new DQUpdateColumn("Product_ID", ProductID));
|
|
update.Columns.Add(new DQUpdateColumn("Product_Name", ProductName));
|
|
session.ExecuteNonQuery(update);
|
|
session.Commit();
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|