public ErrorFlow CreateErrorOrder(ErrorType_Enum type,string errdesc,IEnumerable<OrderFlow> orders)
        {
            ErrorFlow err = new ErrorFlow();

            err.ErrorType = (int)type;
            err.ErrorDescription = errdesc;
            err.ErrorFlowState = (int)ErrorFlowState_Enum.Awaiting;

            foreach (OrderFlow o in orders)
            {
                o.OrderState = (int)OrderState_Enum.Error;
                o.ErrorOrderType = (int)ErrorOrderType_Enum.ErrorOrder;
                o.ErrorFlow = err;
            }

            err.UpdateCreator();

            ErrorOrderLog(err, Operate_Enum.ErrorOrder_Create);

            return err;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the ErrorFlowSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToErrorFlowSet(ErrorFlow errorFlow)
 {
     base.AddObject("ErrorFlowSet", errorFlow);
 }
 /// <summary>
 /// Create a new ErrorFlow object.
 /// </summary>
 /// <param name="errorFlowId">Initial value of the ErrorFlowId property.</param>
 /// <param name="errorType">Initial value of the ErrorType property.</param>
 /// <param name="errorDescription">Initial value of the ErrorDescription property.</param>
 /// <param name="createUser">Initial value of the CreateUser property.</param>
 /// <param name="createTime">Initial value of the CreateTime property.</param>
 /// <param name="timeStamp">Initial value of the TimeStamp property.</param>
 public static ErrorFlow CreateErrorFlow(global::System.Int32 errorFlowId, global::System.Int32 errorType, global::System.String errorDescription, global::System.String createUser, global::System.DateTime createTime, global::System.Byte[] timeStamp)
 {
     ErrorFlow errorFlow = new ErrorFlow();
     errorFlow.ErrorFlowId = errorFlowId;
     errorFlow.ErrorType = errorType;
     errorFlow.ErrorDescription = errorDescription;
     errorFlow.CreateUser = createUser;
     errorFlow.CreateTime = createTime;
     errorFlow.TimeStamp = timeStamp;
     return errorFlow;
 }
        public void StartErrorOrder(ErrorFlow err)
        {
            CreateOrderFromError(err);

            err.ErrorFlowState = (int)ErrorFlowState_Enum.Processing;
            err.UpdateProcesser();

            ErrorOrderLog(err, Operate_Enum.ErrorOrder_Start);
        }
        public void FinishErrorOrder(ErrorFlow err)
        {
            err.ErrorFlowState = (int)ErrorFlowState_Enum.Finish;

            ErrorOrderLog(err, Operate_Enum.ErrorOrder_Finish);

            foreach (OrderFlow od in err.OrderFlow)
            {
                if (od.ErrorOrderType == (int)ErrorOrderType_Enum.CreateOrder)
                {
                    od.ErrorFlow = null;
                    CommitOrder(od);
                }
                else
                {
                    od.ErrorFlow = null;
                    DeleteOrder(od);
                }
            }

            this.ErrorFlows.Remove(err);
        }
        public void ErrorOrderLog(ErrorFlow err, Operate_Enum operate)
        {
            //串行化
            NitpickHouse.Serial.ErrorFlow serr = NitpickHouse.Serial.ErrorFlow.Create(err);
            string desc = NitpickHouse.Serial.JsonUtil.Serialize<NitpickHouse.Serial.ErrorFlow>(serr);

            CreateLog(OperateType_Enum.OperateErrorOrder, operate, err.ErrorFlowId, desc);
        }
        public OrderFlow CreateOrderFromError(ErrorFlow error)
        {
            OrderFlow order = InnerCreateOrder();

            foreach (OrderFlow o in error.OrderFlow)
            {
                foreach (Apartment apt in o.Apartment)
                {
                    apt.SellStateEnum = SellState_Enum.Locked;
                    apt.OrderFlow = order;
                }

                foreach (PreprocessOrder pre in o.PreprocessOrder)
                {
                    pre.IsProcessed = true;
                    pre.OrderFlow = order;
                }
                //不检查重复性
                foreach (OldHouse house in o.OldHouse)
                {
                    OldHouse newh = new OldHouse();
                    newh.RegionType = house.RegionType;
                    newh.OwnershipType = house.OwnershipType;
                    newh.Organization = house.Organization;
                    newh.CertificateType = house.CertificateType;
                    newh.CertificateNo = house.CertificateNo;
                    newh.Address = house.Address;
                    newh.PropertyArea = house.PropertyArea;
                    newh.MeasureArea = house.MeasureArea;
                    newh.EvaluationTotalPrice = house.EvaluationTotalPrice;
                    newh.Memo = house.Memo;

                    order.OldHouse.Add(newh);
                }
                //不检查重复性
                foreach (Consumer user in o.Consumer)
                {
                    Consumer con = new Consumer();
                    con.Name = user.Name;
                    con.IdentityType = user.IdentityType;
                    con.IdentityCardNo = user.IdentityCardNo;
                    con.Memo = user.Memo;

                    order.Consumer.Add(con);
                }
                //不添加HouseOwener

                order.QueueNo = o.QueueNo;
            }
            //新单设置成错误状态,以免其他人删除,处理完成后设置成其他状态
            order.OrderState = (int)OrderState_Enum.Error;

            order.ErrorOrderType = (int)ErrorOrderType_Enum.CreateOrder;
            order.ErrorFlow = error;

            this.OrderFlows.Add(order);

            //从服务器更新用户名和时间
            order.UpdateCreator();

            OrderFlowLog(order, Operate_Enum.Order_Create_Error);

            return order;
        }