Exemplo n.º 1
0
 /// 补录数据
 /// <summary>
 /// 补录数据
 /// </summary>
 /// <returns></returns>
 public bool AddCallRecordNew(CallRecord_ORIG model)
 {
     try
     {
         bool   isOK = false;
         string msg  = "";
         if (model != null)
         {
             Loger.Log4Net.Info("[CallRecordHelper][AddCallRecordNew] 检查是否存在该数据");
             var old_model = crService.GetCallRecord_ORIGByCallID(CallRecordAuthorizeCode, model.CallID.Value, ref msg);
             if (old_model == null)
             {
                 Loger.Log4Net.Info("[CallRecordHelper][AddCallRecordNew] 不存在:InsertCallRecord");
                 isOK = crService.InsertCallRecord(CallRecordAuthorizeCode, model, ref msg);
                 Loger.Log4Net.Info("[CallRecordHelper][AddCallRecordNew] InsertCallRecord:" + isOK + " " + msg);
             }
             else
             {
                 isOK = true;
             }
         }
         return(isOK);
     }
     catch (Exception ex)
     {
         Loger.Log4Net.Error("[CallRecordHelper][AddCallRecordNew]", ex);
         return(false);
     }
 }
        public bool InsertCallRecordWB(string Verifycode, Entities.CallRecord_ORIG model, ref string msg)
        {
            if (BLL.CallRecord_ORIG_Authorizer.Instance.Verify(Verifycode, 0, ref msg, "存储话务数据,授权失败。"))
            {
                CallRecord_ORIG model_ORIG = null;
                model_ORIG = (model != null && model.CallID != null ? BLL.CallRecord_ORIG.Instance.GetCallRecord_ORIGByCallID(Int64.Parse(model.CallID.ToString())) : null);

                if ((model == null || (model != null && model.CallID == null)) &&
                    model_ORIG == null)
                {
                    msg = "参数CallRecord_ORIG的Model为空"; return(false);
                }
                /*根据model.CallID,插入记录到表CallIDMapping中,若CallID和CurrentTime内容存在,则不做插入操作*/
                if (model != null && model_ORIG == null)
                {
                    InsertCallRecord_ORIGWB(model);
                    //if (model.CallStatus == 2)
                    //    InsertCallRecord_ORIG_Business(model);
                }
                else if (model != null && model_ORIG != null)
                {
                    UpdateCallRecord_ORIG(model);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// 话务数据备份
        /// <summary>
        /// 话务数据备份
        /// </summary>
        public static void WriteCallDataBackUp(CallRecord_ORIG BackupModel)
        {
            string fpath = AppDomain.CurrentDomain.BaseDirectory + "log\\CallRecord_ORIG\\SendError_" + DateTime.Today.ToString("yyyy_MM_dd") + ".txt";

            string path = Path.GetDirectoryName(fpath);

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }

            if (!File.Exists(fpath))
            {
                FileInfo   myfile = new FileInfo(fpath);
                FileStream fs     = myfile.Create();
                fs.Close();
            }

            StreamWriter sw = File.AppendText(fpath);

            string sContent = "话务数据备份-" + DateTime.Now.ToString() + "\r\n";

            if (BackupModel != null)
            {
                sContent += "SessionID:" + (BackupModel.SessionID == null ? "null" : BackupModel.SessionID) + ",\r\n";
                sContent += "CallID:" + (BackupModel.CallID.HasValue ? BackupModel.CallID.Value.ToString() : "null") + ",\r\n";
                sContent += "ExtensionNum:" + (BackupModel.ExtensionNum == null ? "null" : BackupModel.ExtensionNum) + ",\r\n";
                sContent += "PhoneNum:" + (BackupModel.PhoneNum == null ? "null" : BackupModel.PhoneNum) + ",\r\n";
                sContent += "ANI:" + (BackupModel.ANI == null ? "null" : BackupModel.ANI) + ",\r\n";
                sContent += "CallStatus:" + (BackupModel.CallStatus.HasValue ? BackupModel.CallStatus.ToString() : "null") + ",\r\n";

                sContent += "SwitchINNum:" + (BackupModel.SwitchINNum == null ? "null" : BackupModel.SwitchINNum) + ",\r\n";
                sContent += "OutBoundType:" + (BackupModel.OutBoundType.HasValue ? BackupModel.OutBoundType.ToString() : "null") + ",\r\n";
                sContent += "SkillGroup:" + (BackupModel.SkillGroup == null ? "null" : BackupModel.SkillGroup) + ",\r\n";
                sContent += "InitiatedTime:" + (BackupModel.InitiatedTime.HasValue ? BackupModel.InitiatedTime.ToString() : "null") + ",\r\n";
                sContent += "RingingTime:" + (BackupModel.RingingTime.HasValue ? BackupModel.RingingTime.ToString() : "null") + ",\r\n";
                sContent += "EstablishedTime:" + (BackupModel.EstablishedTime.HasValue ? BackupModel.EstablishedTime.ToString() : "null") + ",\r\n";

                sContent += "AgentReleaseTime:" + (BackupModel.AgentReleaseTime.HasValue ? BackupModel.AgentReleaseTime.ToString() : "null") + ",\r\n";
                sContent += "CustomerReleaseTime:" + (BackupModel.CustomerReleaseTime.HasValue ? BackupModel.CustomerReleaseTime.ToString() : "null") + ",\r\n";
                sContent += "AfterWorkBeginTime:" + (BackupModel.AfterWorkBeginTime.HasValue ? BackupModel.AfterWorkBeginTime.ToString() : "null") + ",\r\n";
                sContent += "AfterWorkTime:" + (BackupModel.AfterWorkTime.HasValue ? BackupModel.AfterWorkTime.ToString() : "null") + ",\r\n";
                sContent += "ConsultTime:" + (BackupModel.ConsultTime.HasValue ? BackupModel.ConsultTime.ToString() : "null") + ",\r\n";
                sContent += "ReconnectCall:" + (BackupModel.ReconnectCall.HasValue ? BackupModel.ReconnectCall.ToString() : "null") + ",\r\n";

                sContent += "TallTime:" + (BackupModel.TallTime.HasValue ? BackupModel.TallTime.ToString() : "null") + ",\r\n";
                sContent += "AudioURL:" + (BackupModel.AudioURL == null ? "null" : BackupModel.AudioURL) + ",\r\n";
                sContent += "CreateTime:" + (BackupModel.CreateTime.HasValue ? BackupModel.CreateTime.ToString() : "null") + ",\r\n";
                sContent += "CreateUserID:" + (BackupModel.CreateUserID.HasValue ? BackupModel.CreateUserID.ToString() : "null") + ",\r\n";
                sContent += "TransferInTime:" + (BackupModel.TransferInTime.HasValue ? BackupModel.TransferInTime.ToString() : "null") + ",\r\n";
                sContent += "TransferOutTime:" + (BackupModel.TransferOutTime.HasValue ? BackupModel.TransferOutTime.ToString() : "null") + "\r\n";
            }

            sw.WriteLine(sContent);
            sw.Flush();
            sw.Close();
        }
        /// 更新话后信息
        /// <summary>
        /// 更新话后信息
        /// </summary>
        public void UpdateCallRecordAfterTime()
        {
            //初始化话务数据
            DateTime date = Common.GetCurrentTime();

            //更新退出话后时间
            SetAfterWorkTime(date);
            //更新话后数据 (只更新,不插入)
            bool a = CallRecordHelper.Instance.InsertCallRecordNew(true);

            //数据还原
            CallRecordORIG = null;
            Loger.Log4Net.Info("[==BusinessProcess=][UpdateCallRecordAfterTime] 更新话后信息 " + a);
        }
        public bool InsertCallRecord(string Verifycode, Entities.CallRecord_ORIG model, ref string msg)
        {
            if (BLL.CallRecord_ORIG_Authorizer.Instance.Verify(Verifycode, 0, ref msg, "存储话务数据,授权失败。"))
            {
                CallRecord_ORIG model_ORIG = null;
                model_ORIG = (model != null && model.CallID != null ? BLL.CallRecord_ORIG.Instance.GetCallRecord_ORIGByCallID(Int64.Parse(model.CallID.ToString())) : null);

                if ((model == null || (model != null && model.CallID == null)) && model_ORIG == null)
                {
                    msg = "参数CallRecord_ORIG的Model为空";
                    BLL.Loger.Log4Net.Info(msg);
                    return(false);
                }

                if (model != null && string.IsNullOrEmpty(model.SwitchINNum) && !string.IsNullOrEmpty(model.SkillGroup))
                {
                    //落地号码不存在,技能组存在,反查落地号码
                    DataTable dt = BitAuto.ISDC.CC2012.BLL.CallDisplay.Instance.GetCallDisplayByManufacturerSGID(model.SkillGroup);
                    if (dt.Rows.Count > 0)
                    {
                        model.SwitchINNum = CommonFunction.ObjectToString(dt.Rows[0]["AreaCode"]) + CommonFunction.ObjectToString(dt.Rows[0]["TelMainNum"]);
                    }
                }

                /*根据model.CallID,插入记录到表CallIDMapping中,若CallID和CurrentTime内容存在,则不做插入操作*/
                if (model != null && model_ORIG == null)
                {
                    BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord ...InsertCallRecord_ORIG...CallID:" + model.CallID);
                    InsertCallRecord_ORIG(model);
                }
                else if (model != null && model_ORIG != null)
                {
                    BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord ...UpdateCallRecord_ORIG...CallID:" + model.CallID);
                    UpdateCallRecord_ORIG(model);
                }
                else
                {
                    BLL.Loger.Log4Net.Info("条件不满足,无法入库!");
                }
                return(true);
            }
            else
            {
                BLL.Loger.Log4Net.Info("存储话务数据,授权失败:" + msg);
            }
            return(false);
        }
 /// 获取话务类
 /// <summary>
 /// 获取话务类
 /// </summary>
 /// <param name="callid"></param>
 /// <param name="calltype"></param>
 /// <returns></returns>
 public void InitCallRecordORIG(long callid, Calltype calltype)
 {
     CallRecordORIG               = new CallRecord_ORIG();
     CallRecordORIG.CallID        = callid;
     CallRecordORIG.SiemensCallID = -1;
     CallRecordORIG.ExtensionNum  = LoginUser.ExtensionNum;
     //设置主叫和被叫
     CallRecordORIG.CallStatus = (int)calltype;
     SetPhoneNumAndAni();
     CallRecordORIG.OutBoundType  = (int)OutBoundType;
     CallRecordORIG.AfterWorkTime = 0;
     CallRecordORIG.TallTime      = 0;
     CallRecordORIG.CreateTime    = Common.GetCurrentTime();
     CallRecordORIG.CreateUserID  = LoginUser.UserID;
     //设置厂家id
     CallRecordORIG.SessionID     = HollyContactHelper.Instance.GetHollyCallID(); //厂家callid
     CallRecordORIG.GenesysCallID = HollyContactHelper.Instance.GetHollyCallID(); //厂家callid
     Loger.Log4Net.Info("[==BusinessProcess=] InitCallRecordORIG callid:" + callid + "-calltype:" + calltype);
 }
        private int InsertCallRecord_ORIG_Business(CallRecord_ORIG model)
        {
            BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG_Business BEGIN...");

            int    retval = 0;
            string str    = "";

            str = BitAuto.ISDC.CC2012.BLL.AgentTimeState.Instance.GetBGNameAndOutNum(Convert.ToInt32(model.CreateUserID));
            int bgid = 0;

            if (!string.IsNullOrEmpty(str))
            {
                string[] strArray = str.Split(',');
                bgid = Convert.ToInt32(strArray[0]);

                CallRecord_ORIG_Business bmodel = new CallRecord_ORIG_Business();
                bmodel.CreateUserID = model.CreateUserID;
                bmodel.CreateTime   = model.CreateTime;
                bmodel.CallID       = Convert.ToInt64(model.CallID);
                bmodel.BGID         = bgid;
                //查询现在表
                if (!BLL.CallRecord_ORIG_Business.Instance.IsExistsByCallID(Convert.ToInt64(model.CallID)))
                {
                    BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG_Business ...中间表数据不存在...CallID:" + model.CallID);
                    retval = BitAuto.ISDC.CC2012.BLL.CallRecord_ORIG_Business.Instance.Insert(bmodel);
                }
                else
                {
                    BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG_Business ...中间表数据存在...CallID:" + model.CallID);
                }
            }
            else
            {
                BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG_Business ...当前用户所属业务组为空");
            }

            return(retval);
        }
        private int InsertCallRecord_ORIGWB(CallRecord_ORIG model)
        {
            int retval = 0;

            retval = BitAuto.ISDC.CC2012.BLL.CallRecord_ORIG.Instance.Insert(model);

            if (retval > 0)
            {
                //if (model.OutBoundType == 2)//客户端外呼
                //{
                //    BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG WB ...客户端外呼话务保存...");
                //    InsertCallRecord_ORIG_Business(model);
                //}

                BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG WB ...话务中间表保存...");
                InsertCallRecord_ORIG_Business(model);
            }
            else
            {
                BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG WB...失败...");
            }

            return(retval);
        }
        private int InsertCallRecord_ORIG(CallRecord_ORIG model)
        {
            //int userID;

            //if (int.TryParse(model.CreateUserID.ToString(), out userID))
            //{
            //    try
            //    {
            //        BLL.Loger.Log4Net.Info("[CallRecordService.asmx]GetEmployeeDomainAccountByEid" + userID);
            //        string domainAccount = BLL.Util.GetEmployeeDomainAccountByEid(userID);
            //        //根据域账号找到权限系统该人员的主键
            //        BLL.Loger.Log4Net.Info("[CallRecordService.asmx]GetUserIDByNameDomainAccount" + domainAccount);
            //        model.CreateUserID = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetUserIDByNameDomainAccount(domainAccount);
            //    }
            //    catch
            //    {
            //    }
            //}

            BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG" + model.CallID);
            int retval = 0;

            retval = BitAuto.ISDC.CC2012.BLL.CallRecord_ORIG.Instance.Insert(model);

            if (retval > 0)
            {
                BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG ...话务中间表保存...CallID:" + model.CallID);
                InsertCallRecord_ORIG_Business(model);
            }
            else
            {
                BLL.Loger.Log4Net.Info("[CallRecordService.asmx]InsertCallRecord_ORIG ...失败...");
            }

            return(retval);
        }
        //此方法是统计外呼失败坐席所属业务组添加的,经分析后觉得不合理弃用

        /*
         * private int InsertCallRecord_ORIG_Business(CallRecord_ORIG model)
         * {
         *  BLL.Loger.Log4Net.Info("InsertCallRecord_ORIG_Business BEGIN...");
         *  int userID;
         *
         *  if (int.TryParse(model.CreateUserID.ToString(), out userID))
         *  {
         *      string domainAccount = BLL.Util.GetEmployeeDomainAccountByEid(userID);
         *      //根据域账号找到权限系统该人员的主键
         *      model.CreateUserID = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetUserIDByNameDomainAccount(domainAccount);
         *  }
         *
         *  string bgids = "";
         *  bgids = BitAuto.ISDC.CC2012.BLL.AgentTimeState.Instance.GetUserGroupIDsStr(userID);
         *  BLL.Loger.Log4Net.Info("InsertCallRecord_ORIG_Business bgids...IS:" + bgids);
         *  string[] array = bgids.Split(',');
         *  for (int i = 0; i < array.Length; i++)
         *  {
         *      CallRecord_ORIG_Business bmodel = new CallRecord_ORIG_Business();
         *      bmodel.CreateUserID = model.CreateUserID;
         *      bmodel.CreateTime = model.CreateTime;
         *      bmodel.CallID = Convert.ToInt64(model.CallID);
         *      bmodel.BGID = Convert.ToInt32(array[i]);
         *      BitAuto.ISDC.CC2012.BLL.CallRecord_ORIG_Business.Instance.Insert(bmodel);
         *  }
         *  return 1;
         * }
         */
        #endregion

        #region 修改

        private int UpdateCallRecord_ORIG(CallRecord_ORIG model)
        {
            BLL.Loger.Log4Net.Info("[CallRecordService.asmx]UpdateCallRecord_ORIG" + model.CallID);
            return(BitAuto.ISDC.CC2012.BLL.CallRecord_ORIG.Instance.Update(model));
        }