private void DealerSubmit(out string msg)
        {
            msg = string.Empty;
            try
            {
                BLL.Loger.Log4Net.Info("【经销商工单提交Step1——参数验证】CallID IS:" + CallID);

                #region 验证
                validate(out msg);
                if (LastProcessDate != string.Empty)
                {
                    DateTime dtLastProcessDate;
                    if (DateTime.TryParse(LastProcessDate, out dtLastProcessDate))
                    {
                        if (dtLastProcessDate < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")))
                        {
                            msg += "最晚处理日期不能小于当前时间!<br/>";
                        }
                    }
                }

                if (msg != string.Empty)
                {
                    msg = "{'result':'false','msg':'" + msg + "'}";

                    return;
                }
                #endregion

                #region 插入工单表
                BLL.Loger.Log4Net.Info("【经销商工单提交Step2——绑定工单信息】");
                Entities.WorkOrderInfo model_WorkOrderInfo = bindWorkOrderInfo(out msg);

                if (msg != string.Empty)
                {
                    return;
                }

                string orderCustID = string.Empty;
                //根据CRMCustName查询获取CustID
                BLL.Loger.Log4Net.Info("【经销商工单提交Step3——根据CRMCustName查询获取CustID开始】");
                DataSet ds_CustID = BitAuto.YanFa.Crm2009.BLL.CustInfo.Instance.GetCustIDByNameToCC(model_WorkOrderInfo.CustName);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step3——根据CRMCustName查询获取CustID结束】");
                if (ds_CustID != null && ds_CustID.Tables.Count > 0 && ds_CustID.Tables[0].Rows.Count > 0)
                {
                    model_WorkOrderInfo.CRMCustID = orderCustID = ds_CustID.Tables[0].Rows[0]["CustID"].ToString();
                }

                //OperType=1:添加(状态:已完成);OperType=2:转出(状态:待审核)
                model_WorkOrderInfo.WorkOrderStatus = OperType == "1" ? (int)Entities.WorkOrderStatus.Completed : (int)Entities.WorkOrderStatus.Pending;

                model_WorkOrderInfo.WorkCategory = 2;//工单类型-经销商;add lxw 13.9.11

                model_WorkOrderInfo.DemandID = DemandID;
                BLL.Loger.Log4Net.Info("【经销商工单提交Step4——WorkOrderInfo入库开始】");
                model_WorkOrderInfo.OrderID = BLL.WorkOrderInfo.Instance.Insert(model_WorkOrderInfo);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step4——WorkOrderInfo入库结束】OrderID=:" + OrderID);


                //回写IM库
                BLL.Loger.Log4Net.Info("【经销商工单提交Step5——工单信息回写IM库开始】");
                UpdateCCWorkOrder2IM(model_WorkOrderInfo);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step5——工单信息回写IM库结束】");
                #endregion

                #region 插入工单回复表
                BLL.Loger.Log4Net.Info("【经销商工单提交Step6——绑定工单回复信息】OrderID=" + model_WorkOrderInfo.OrderID + ",CallID=" + CallID);
                Entities.WorkOrderRevert model_Revert = bindWorkOrderRevert(out msg);

                model_Revert.OrderID = model_WorkOrderInfo.OrderID;
                if (CallID != string.Empty)
                {
                    model_Revert.CallID = Int64.Parse(CallID);
                }

                if (msg != string.Empty)
                {
                    return;
                }

                model_Revert.WorkOrderStatus = OperType == "1" ? "已完成" : "待审核";
                BLL.Loger.Log4Net.Info("【经销商工单提交Step7——根据部门获取部门名称开始】");
                model_Revert.ReceiverDepartName = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetDistrictNameByUserID(operUserID);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step7——根据部门获取部门名称结束】");

                BLL.Loger.Log4Net.Info("【经销商工单提交Step8——工单回复信息入库开始】");
                BLL.WorkOrderRevert.Instance.Insert(model_Revert);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step8——工单回复信息入库结束】");
                #endregion

                #region 插入标签
                if (TagIDs != string.Empty)
                {
                    string[] array_TagIDs = TagIDs.Split(',');
                    for (int k = 0; k < array_TagIDs.Length; k++)
                    {
                        Entities.WorkOrderTagMapping model_Mapping = new Entities.WorkOrderTagMapping();
                        model_Mapping.OrderID      = model_WorkOrderInfo.OrderID;
                        model_Mapping.TagID        = int.Parse(array_TagIDs[k]);
                        model_Mapping.Status       = 0;
                        model_Mapping.CreateTime   = model_Mapping.ModifyTime = operTime;
                        model_Mapping.CreateUserID = model_Mapping.ModifyUserID = operUserID;
                        BLL.Loger.Log4Net.Info("【经销商工单提交Step9——插入标签开始】");
                        BLL.WorkOrderTagMapping.Instance.Insert(model_Mapping);
                        BLL.Loger.Log4Net.Info("【经销商工单提交Step9——插入标签结束】");
                    }
                }

                #endregion

                #region 把工单联系人插入个人用户
                Web.AjaxServers.CustBaseInfo.CustBasicInfo model_cbInfo = bindCustBasicInfo(out msg);
                if (msg != string.Empty)
                {
                    return;
                }
                Web.AjaxServers.CustBaseInfo.OperPopCustBasicInfo cbi = new Web.AjaxServers.CustBaseInfo.OperPopCustBasicInfo();
                BLL.Loger.Log4Net.Info("【经销商工单提交Step10——插入个人用户库信息开始】");
                cbi.InsertCustInfo(model_cbInfo, out msg);
                BLL.Loger.Log4Net.Info("【经销商工单提交Step10——插入个人用户库信息结束】");
                string   ccCustID = string.Empty;
                string[] aMsg     = msg.Split(',');
                //如果不存在会新增个人用户 返回ccCustID
                //如果存在会直接返回该联系人ccCustID
                if (aMsg.Length == 2 && aMsg[0].Split(':')[1] == "'true'")
                {
                    ccCustID = aMsg[1].Split(':')[1].Replace("'", "");
                }
                #endregion

                #region 插入访问记录
                if (ccCustID != string.Empty)
                {
                    BLL.Loger.Log4Net.Info("【经销商工单提交Step11——插入联系记录开始】");
                    long callid = CommonFunction.ObjectToLong(CallID, -2);
                    int  userid = BLL.Util.GetLoginUserID();

                    BitAuto.ISDC.CC2012.Web.AjaxServers.CustBaseInfo.OperPopCustBasicInfo.OperCustVisitBusiness(ccCustID, model_WorkOrderInfo.OrderID, callid, (int)VisitBusinessTypeEnum.S1_工单, TaskSource, userid, model_WorkOrderInfo.ContactTel);
                    BLL.Loger.Log4Net.Info("【经销商工单提交Step11——插入联系记录结束】");
                }
                #endregion

                msg = "{'result':'true','OrderID':'" + model_WorkOrderInfo.OrderID + "','orderCustID':'" + orderCustID + "'}";
            }
            catch (Exception ex)
            {
                BLL.Loger.Log4Net.Error("【经销商工单提交】出现方法出现问题:" + ex.Message);
            }
        }
        private void PersonalSubmit(out string msg)
        {
            msg = string.Empty;
            try
            {
                BLL.Loger.Log4Net.Info("【个人工单提交Step1——数据验证】");
                #region 验证

                validate(out msg);

                if (msg != string.Empty)
                {
                    msg = "{'result':'false','msg':'" + msg + "'}";
                    return;
                }

                #endregion

                #region 插入工单表

                Entities.WorkOrderInfo model_WorkOrderInfo = bindWorkOrderInfo(out msg);

                if (msg != string.Empty)
                {
                    return;
                }

                //个人类型增加工单,状态默认-已完成
                model_WorkOrderInfo.WorkOrderStatus = (int)Entities.WorkOrderStatus.Completed;

                model_WorkOrderInfo.WorkCategory = 1;//工单类型-个人;add lxw 13.9.11
                BLL.Loger.Log4Net.Info("【个人工单提交Step2——添加工单开始】");
                model_WorkOrderInfo.OrderID = BLL.WorkOrderInfo.Instance.Insert(model_WorkOrderInfo);
                BLL.Loger.Log4Net.Info("【个人工单提交Step2——添加工单结束】OrderID=" + model_WorkOrderInfo.OrderID);
                //回写IM库
                BLL.Loger.Log4Net.Info("【个人工单提交Step3——工单数据回写IM开始】");
                UpdateCCWorkOrder2IM(model_WorkOrderInfo);
                BLL.Loger.Log4Net.Info("【个人工单提交Step3——工单数据回写IM结束】");
                #endregion

                //如果有推荐活动,插入WorkOrderActivity表,add lxw 13.1.14
                #region 插入推荐活动

                if (ActivityIDs != "")
                {
                    string[] aIDs = ActivityIDs.Split(',');
                    for (int i = 0; i < aIDs.Length; i++)
                    {
                        Entities.WorkOrderActivity model_Activity = new Entities.WorkOrderActivity();
                        model_Activity.ActivityGUID = new Guid(aIDs[i]);
                        model_Activity.OrderID      = model_WorkOrderInfo.OrderID;
                        model_Activity.CreateTime   = operTime;
                        model_Activity.CreateUserID = operUserID;
                        BLL.Loger.Log4Net.Info("【个人工单提交Step4——WorkOrderActivity数据入库开始】");
                        BLL.WorkOrderActivity.Instance.Insert(model_Activity);
                        BLL.Loger.Log4Net.Info("【个人工单提交Step4——WorkOrderActivity数据入库结束】");
                    }
                }

                #endregion

                #region 插入工单回复表

                Entities.WorkOrderRevert model_Revert = bindWorkOrderRevert(out msg);

                if (msg != string.Empty)
                {
                    return;
                }

                model_Revert.OrderID            = model_WorkOrderInfo.OrderID;
                model_Revert.ReceiverDepartName = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetDistrictNameByUserID(operUserID);
                model_Revert.WorkOrderStatus    = "已完成";
                if (CallID != string.Empty)
                {
                    model_Revert.CallID = Int64.Parse(CallID);
                }
                BLL.Loger.Log4Net.Info("【个人工单提交Step5——WorkOrderRevert数据入库开始】");
                BLL.WorkOrderRevert.Instance.Insert(model_Revert);
                BLL.Loger.Log4Net.Info("【个人工单提交Step5——WorkOrderRevert数据入库结束】");
                #endregion

                #region 插入标签

                if (TagIDs != string.Empty)
                {
                    string[] array_TagIDs = TagIDs.Split(',');
                    for (int k = 0; k < array_TagIDs.Length; k++)
                    {
                        Entities.WorkOrderTagMapping model_Mapping = new Entities.WorkOrderTagMapping();
                        model_Mapping.OrderID      = model_WorkOrderInfo.OrderID;
                        model_Mapping.TagID        = int.Parse(array_TagIDs[k]);
                        model_Mapping.Status       = 0;
                        model_Mapping.CreateTime   = model_Mapping.ModifyTime = operTime;
                        model_Mapping.CreateUserID = model_Mapping.ModifyUserID = operUserID;
                        BLL.Loger.Log4Net.Info("【个人工单提交Step6——插入标签数据入库开始】");
                        BLL.WorkOrderTagMapping.Instance.Insert(model_Mapping);
                        BLL.Loger.Log4Net.Info("【个人工单提交Step6——插入标签数据入库结束】");
                    }
                }

                #endregion
                msg = "{'result':'true','OrderID':'" + model_WorkOrderInfo.OrderID + "'}";
            }
            catch (Exception ex)
            {
                BLL.Loger.Log4Net.Error("【个人工单提交】出现方法出现问题:" + ex.Message);
            }
        }
        //编辑工单回复表信息
        private void EditWorkOrderRevert(Entities.WorkOrderInfo newModel, Entities.WorkOrderInfo oldModel, out string msg)
        {
            msg = string.Empty;

            if (newModel == null || oldModel == null)
            {
                return;
            }

            Entities.WorkOrderRevert model_Revert = new Entities.WorkOrderRevert();

            Int64 callID = 0;

            if (Int64.TryParse(CallID, out callID))
            {
                //如果有录音,则在之前的录音记录的基础上进行回复表的修改
                model_Revert = BLL.WorkOrderRevert.Instance.GetWorkOrderRevertByCallID(callID);
            }
            else
            {
                model_Revert.OrderID      = oldModel.OrderID;
                model_Revert.CreateTime   = operTime;
                model_Revert.CreateUserID = operUserID;
            }
            model_Revert.RevertContent      = RevertContent;
            model_Revert.ReceiverDepartName = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetDistrictNameByUserID(operUserID);

            model_Revert.IsReturnVisit = RevertContent == string.Empty ? "否" : "是";

            //比较工单分类
            if (newModel.CategoryID != oldModel.CategoryID)
            {
                string oldCategoryName = BLL.WorkOrderCategory.Instance.GetCategoryFullName(oldModel.CategoryID.ToString());

                string newCategoryName = BLL.WorkOrderCategory.Instance.GetCategoryFullName(newModel.CategoryID.ToString());

                model_Revert.CategoryName = fieldDesc(oldCategoryName, newCategoryName);
            }

            //比较工单状态
            if (newModel.WorkOrderStatus != oldModel.WorkOrderStatus)
            {
                string oldStatus = BLL.Util.GetEnumOptText(typeof(Entities.WorkOrderStatus), (int)oldModel.WorkOrderStatus);

                string newStatus = BLL.Util.GetEnumOptText(typeof(Entities.WorkOrderStatus), (int)newModel.WorkOrderStatus);

                model_Revert.WorkOrderStatus = fieldDesc(oldStatus, newStatus);
            }

            //比较优先级
            if (newModel.PriorityLevel != oldModel.PriorityLevel)
            {
                string oldLevel = oldModel.PriorityLevel == 1 ? "普通" : "紧急";

                string newLevel = newModel.PriorityLevel == 1 ? "普通" : "紧急";

                model_Revert.PriorityLevelName = fieldDesc(oldLevel, newLevel);
            }

            //比较接收人
            if (!string.IsNullOrEmpty(newModel.ReceiverName) || !string.IsNullOrEmpty(oldModel.ReceiverName))
            {
                model_Revert.ReceiverID   = newModel.ReceiverID.ToString();
                model_Revert.ReceiverName = fieldDesc(oldModel.ReceiverName, newModel.ReceiverName);
            }

            //比较是否投诉
            if (newModel.IsComplaintType != oldModel.IsComplaintType)
            {
                string oldIsComplaint = oldModel.IsComplaintType == true ? "投诉" : "普通";

                string newIsComplaint = newModel.IsComplaintType == true ? "投诉" : "普通";

                model_Revert.IsComplaintType = fieldDesc(oldIsComplaint, newIsComplaint);
            }

            //比较标签
            string tagDesc = GetCompareTagDesc(model_Revert.OrderID, TagIDs);

            if (tagDesc != string.Empty)
            {
                model_Revert.TagName = tagDesc;

                //修改标签表
                BLL.WorkOrderTagMapping.Instance.DeleteByOrderID(model_Revert.OrderID);

                if (TagIDs != string.Empty)
                {
                    string[] array_TagIDs = TagIDs.Split(',');
                    for (int k = 0; k < array_TagIDs.Length; k++)
                    {
                        Entities.WorkOrderTagMapping model_Mapping = new Entities.WorkOrderTagMapping();
                        model_Mapping.OrderID      = model_Revert.OrderID;
                        model_Mapping.TagID        = int.Parse(array_TagIDs[k]);
                        model_Mapping.Status       = 0;
                        model_Mapping.CreateTime   = model_Mapping.ModifyTime = operTime;
                        model_Mapping.CreateUserID = model_Mapping.ModifyUserID = operUserID;
                        BLL.WorkOrderTagMapping.Instance.Insert(model_Mapping);
                    }
                }
            }

            if (callID != 0)
            {
                BLL.WorkOrderRevert.Instance.Update(model_Revert);
            }
            else
            {
                BLL.WorkOrderRevert.Instance.Insert(model_Revert);
            }
        }