美文网首页
GCS SERVER 服务端数据走向

GCS SERVER 服务端数据走向

作者: a9b854aded01 | 来源:发表于2017-09-12 09:01 被阅读0次
    Paste_Image.png

    以DayliBusiness类 SaveThrowInBill()为例

    Contract服务层

    
    namespace CMST.SteerMarket.Server.Contract.DayliBusiness
    {
        [ServiceContract]
        public interface IDailyBusiness
        {
            [OperationContract]
            [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
            string SaveThrowInBill(ThrowInEntity tie, string userId, int mode);
    
            [OperationContract]
            [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
            string GetThrowInEntityByID(string throwInId);
    
            [OperationContract]
            [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
            string GetBillOfLading(string BillOfLadingID, string SaleID, string SaleCustoemr, int model);
        }
    }
    

    Service契约层

    namespace CMST.SteerMarket.Server.Service.DailyBusiness
    {
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
        public class DailyBusiness : IDailyBusiness
        {
            DailyBusinessBLL MyDailyBusinessBLL = new DailyBusinessBLL();
    
            public string GetThrowInEntityByID(string throwInId)
            {
                return JsonConvert.SerializeObject(MyDailyBusinessBLL.GetThrowInEntityByID(throwInId));
            }
    
            public string SaveThrowInBill(ThrowInEntity tie, string userId, int mode)
            {
                return JsonConvert.SerializeObject(MyDailyBusinessBLL.SaveThrowInBill(tie, userId, mode));
            }
    
    

    BLL 业务逻辑层

    namespace CMST.SteerMarket.Server.BLL.DailyBusiness
    {
        public class DailyBusinessBLL
        {
            DailyBusinessDAL MyDailyBusinessDAL = new DailyBusinessDAL();
    
            public FeedbackInfomation SaveThrowInBill(ThrowInEntity tie, string userId, int mode)
            {
    
                FeedbackInfomation fi = new FeedbackInfomation();
                try
                {
                    switch (mode)
                    {
                        case 0:
                            tie = SaveThrowInBillInAdd(tie, userId);
                            // fi.Result = tie;
                            fi.ErrorStatus = STATUS_ADAPTER.SAVE_SUCCESS;
                            fi.FeedbackMessage = Tips.SAVE_SUCCESS;
                            break;
                        case 1:
                            tie = SaveThrowInBillInEdit(tie, userId);
                            // fi.Result = tie;
                            fi.ErrorStatus = STATUS_ADAPTER.SAVE_SUCCESS;
                            fi.FeedbackMessage = Tips.SAVE_SUCCESS;
                            break;
                        case 2:
                            tie = SaveThrowInBillChecked(tie, userId);
                            //fi.Result = tie;
                            fi.ErrorStatus = STATUS_ADAPTER.CHECK_SUCCESS;
                            fi.FeedbackMessage = Tips.CHECK_SUCCESS;
                            break;
                        case 3:
                            tie = SaveThrowInBillCancelCheck(tie, userId);
                            //  fi.Result = tie;
                            fi.ErrorStatus = STATUS_ADAPTER.CANCEL_CHECK_SUCCESS;
                            fi.FeedbackMessage = Tips.CANCEL_CHECK_SUCCESS;
                            break;
                    }
                    fi.Result = tie;
                    return fi;
                }
                catch (Exception ex)
                {
                    fi.FeedbackMessage = ex.Message.ToString();
                    fi.ErrorStatus = STATUS_ADAPTER.SAVE_FAILED;
                    return fi;
                }
            }
    
     private ThrowInEntity SaveThrowInBillInAdd(ThrowInEntity tie, string userId)
            {
                try
                {
                    BaseBLL MyBaseBLL = new BaseBLL();
                    if (tie.ThrowInID == null || tie.ThrowInID == "")
                    {
                        TransactionOptions to = new TransactionOptions();
                        to.IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead;
                        to.Timeout = new TimeSpan(0, 0, 60);
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, to))
                        {
                            tie.Maker = userId;
                            tie.MakeTime = DateTime.Now;
                            tie.Reviser = userId;
                            tie.RevisionTime = tie.MakeTime;
                            tie.Status = Status.BillStatus["待审核"];
                            tie = MyDailyBusinessDAL.InsertThrowInEntity(tie);
                            LogEntity le = MyBaseBLL.GenerateLog("日常业务", "投放单", "新增", DateTime.Now, userId, "");
                            le = MyBaseBLL.SaveLog(le);
                            LogDetailEntity lde = MyBaseBLL.GenerateLogDetail(le.LogID, "SAL_ThrowIn", tie.ThrowInID, "");
                            MyBaseBLL.SaveLogDetail(lde);
                            for (int i = 0; i < tie.Tides.Count; i++)
                            {
                                if (tie.Tides[i].IfDel != true)
                                {
                                    tie.Tides[i].ThrowInID = tie.ThrowInID;
                                    SetDataInWhenAddOrEditThrowInDetail(tie.Tides[i]);
                                    tie.Tides[i] = MyDailyBusinessDAL.InsertThrowInDetailEntity(tie.Tides[i]);
                                    LogDetailEntity ldei = MyBaseBLL.GenerateLogDetail(le.LogID, "SAL_ThrowInDetail", tie.Tides[i].ThrowInDetailID, "");
                                    MyBaseBLL.SaveLogDetail(ldei);
                                }
                            }
                            if (tie.Dcs != null)
                            {
                                for (int i = 0; i < tie.Dcs.Count; i++)
                                {
                                    if (tie.Dcs[i].IfUse != false)
                                    {
                                        tie.Dcs[i].ThrowInID = tie.ThrowInID;
                                        tie.Dcs[i] = MyDailyBusinessDAL.InsertDirectionalCustomerEntity(tie.Dcs[i]);
                                        LogDetailEntity ldei = MyBaseBLL.GenerateLogDetail(le.LogID, "SAL_DirectionalCustomer", tie.Dcs[i].DirectionalCustomerID, "");
                                        MyBaseBLL.SaveLogDetail(ldei);
                                    }
                                }
                            }
                            tie.Dcs = tie.Dcs.Where(m => m.IfUse == true).ToList<DirectionalCustomerEntity>();
                            tie.Tides = tie.Tides.Where(m => m.IfDel != true).ToList<ThrowInDetailEntity>();
                            tie = GetThrowInBillPersonAndStatus(tie);
                            scope.Complete();
                        }
                    }
                    else
                    {
                        tie = SaveThrowInBillInEdit(tie, userId);
                    }
                    return tie;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
    

    DAL 持久层

      public ThrowInDetailEntity InsertThrowInDetailEntity(ThrowInDetailEntity tide)
            {
                tide.ThrowInDetailID = (new BaseDAL()).GenerateTableID("STD");
                StringBuilder sb = new StringBuilder(" insert into dbo.SAL_ThrowInDetail ( STD_ID, STI_ID, CP_ID, STD_SinglePrice, STD_MinPrice, STD_MeasureMode, STD_CutLength, STD_PackingNum, STD_SingleW, STD_Num, STD_UnitN, STD_Weight, STD_UnitW, STD_Volume, STD_UnitV, STD_ChargeSign, STD_Remark, STD_CurN, STD_CurW, STD_CurV, STD_FroN, STD_FroW, STD_FroV, STD_PFroN, STD_PFroW, STD_PFroV, STD_Description, STD_IfDel, STD_UpdateTime, STD_BatNo ) values ( ");
                sb.AppendFormat(" '{0}',", tide.ThrowInDetailID);
                sb.AppendFormat(" '{0}',", tide.ThrowInID);
                sb.AppendFormat(" '{0}',", tide.ProductID);
                sb.AppendFormat(" '{0}',", tide.SinglePrice);
                sb.AppendFormat(" '{0}',", tide.MinPrice);
                sb.AppendFormat(" '{0}',", tide.MeasureMode);
                sb.AppendFormat(" '{0}',", tide.CutLength);
                sb.AppendFormat(" '{0}',", tide.PackingNum);
                sb.AppendFormat(" '{0}',", tide.SingleWeight);
                sb.AppendFormat(" '{0}',", tide.Num);
                sb.AppendFormat(" '{0}',", tide.UnitNum);
                sb.AppendFormat(" '{0}',", tide.Weight);
                sb.AppendFormat(" '{0}',", tide.UnitWeight);
                sb.AppendFormat(" '{0}',", tide.Volume);
                sb.AppendFormat(" '{0}',", tide.UnitVolume);
                sb.AppendFormat(" '{0}',", tide.ChargeSign);
                sb.AppendFormat(" '{0}',", tide.Remark);
                sb.AppendFormat(" '{0}',", tide.CurNum);
                sb.AppendFormat(" '{0}',", tide.CurWeight);
                sb.AppendFormat(" '{0}',", tide.CurVolume);
                sb.AppendFormat(" '{0}',", tide.FrozenNum);
                sb.AppendFormat(" '{0}',", tide.FrozenWeight);
                sb.AppendFormat(" '{0}',", tide.FrozenVolume);
                sb.AppendFormat(" '{0}',", tide.PersonFrozenNum);
                sb.AppendFormat(" '{0}',", tide.PersonFrozenWeight);
                sb.AppendFormat(" '{0}',", tide.PersonFrozenVolume);
                sb.AppendFormat(" '{0}',", tide.NumDescription);
                sb.AppendFormat(" '{0}',", tide.IfDel);
                tide.UpdateTime = DateTime.Now;
                tide.TempTime = tide.UpdateTime;
                sb.AppendFormat(" '{0}',", tide.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                sb.AppendFormat(" '{0}' )", tide.BatNo);
    
                SqlDataHelper.ExecSqlWithTips(sb.ToString(), Tips.THROWINDETAIL_INSERT_FAILED);
                return tide;
            }
    ···

    相关文章

      网友评论

          本文标题:GCS SERVER 服务端数据走向

          本文链接:https://www.haomeiwen.com/subject/kxgqsxtx.html