Beispiel #1
0
        private void LoginByPara()
        {
            //string url = "login.aspx";
            string url = "LoginWB.aspx";

            if (!string.IsNullOrEmpty(DomainAccount) && (!string.IsNullOrEmpty(Password) || !string.IsNullOrEmpty(PasswordEncrypt)))
            {
                string pwd = "";
                if (!string.IsNullOrEmpty(Password))
                {
                    pwd = Password;
                }

                if (!string.IsNullOrEmpty(PasswordEncrypt))
                {
                    pwd = BitAuto.Utils.Security.DESEncryptor.Encrypt(PasswordEncrypt);
                }
                int ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(DomainAccount, pwd);
                if (ret > 0)
                {
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                    url = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")

                    DataTable dtParent = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(HttpContext.Current.Session["userid"]), sysID);
                    if (dtParent != null)
                    {
                        DataTable dtChild = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(HttpContext.Current.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                        if (dtChild.Rows.Count > 0)
                        {
                            url = dtChild.Rows[0]["url"].ToString();
                        }
                    }

                    ret = 1;//登陆成功
                    string content = string.Format("用户{1}(ID:{0})登录成功。", HttpContext.Current.Session["userid"], HttpContext.Current.Session["truename"]);
                    BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                }
                Response.Redirect(url);
            }
        }
        private void GetHeLiDataByUserNameAndAgentNum(string TheUserName, string TheAgentNum, out string msg)
        {
            msg = string.Empty;
            string strUrl = ConfigurationUtil.GetAppSettingValue("HeLiURL") + "/busiService/addAgentInfo?"
                            + "userName="******"&agentId=" + TheAgentNum
                            + "&deptId=" + AtGroupID
                            + "&deptName=" + AtGroupName
                            + "&skill=" + ToHeLiSGIDAndPriority;

            try
            {
                HttpWebResponse webResp  = HttpHelper.CreateGetHttpResponse(strUrl);
                string          data     = HttpHelper.GetResponseString(webResp);
                ResultJson      jsondata = (ResultJson)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(data, typeof(ResultJson));
                if (jsondata != null)
                {
                    if (jsondata.returncode == "0")
                    {
                        msg = "{'result':'failure','msg':'合力厂商接口调用失败:" + jsondata.returnmsg + "'}";
                        BLL.Loger.Log4Net.Error("【批量修改用户数据权限】Step3.调用合力厂商接口调用失败:访问url(" + strUrl + "),返回信息[" + jsondata.returnmsg + "]");
                    }
                    else
                    {
                        msg = "{'result':'success'}";
                        BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step3.合力厂商接口调用成功:访问url(" + strUrl + ")");
                    }
                }
                else
                {
                    msg = "{'result':'failure','msg':'合力厂商接口异常,未能返回数据!'}";
                    BLL.Loger.Log4Net.Error("【批量修改用户数据权限】Step3.调用合力厂商接口异常:访问url(" + strUrl + ")未能返回数据!");
                }
            }
            catch (Exception ex)
            {
                msg = "{'result':'failure','msg':'合力厂商接口异常,导致无法访问!'}";
                BLL.Loger.Log4Net.Error("【批量修改用户数据权限】Step3.调用合力厂商接口异常:访问url(" + strUrl + "); ", ex);
            }
        }
Beispiel #3
0
        //汽车金融加密
        public static string Encrypt(string Text, string sKey)
        {
            string Key = ConfigurationUtil.GetAppSettingValue("CarFinancial_GenURLParaMD5");
            DESCryptoServiceProvider des = new DESCryptoServiceProvider();

            byte[] inputByteArray;
            inputByteArray = Encoding.Default.GetBytes(Text);
            des.Key        = ASCIIEncoding.ASCII.GetBytes(Key);
            des.IV         = ASCIIEncoding.ASCII.GetBytes(Key);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            CryptoStream           cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);

            cs.Write(inputByteArray, 0, inputByteArray.Length);
            cs.FlushFinalBlock();
            StringBuilder ret = new StringBuilder();

            foreach (byte b in ms.ToArray())
            {
                ret.AppendFormat("{0:X2}", b);
            }
            return(ret.ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable db = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetRoleInfoBySysID
                               (ConfigurationUtil.GetAppSettingValue("ThisSysID"));

            if (db != null && db.Rows.Count > 0)
            {
                Rpt_Role.DataSource = db;
                Rpt_Role.DataBind();
                GroupDataBind();
            }

            if (IsModfiySingle == "false")
            {
                //如果是批量修改
                this.divAgentNum.Visible = false;
                this.divData.Visible     = false;
            }
            else
            {
                BingData();
            }
        }
Beispiel #5
0
        /// <summary>
        /// 验证授权逻辑
        /// </summary>
        /// <param name="Verifycode">授权码</param>
        /// <param name="status">状态(默认-0,1-工单接口)</param>
        /// <param name="msg">返回信息</param>
        /// <param name="errorMsg">传入信息</param>
        /// <returns>验证通过为True,否则返回False</returns>
        public bool Verify(string Verifycode, int status, ref string msg, string errorMsg)
        {
            //是否启用话务记录保存
            string sVerify = "";

            sVerify = ConfigurationUtil.GetAppSettingValue("CallRecordAuthorizeVerify");
            if (sVerify == "false")
            {
                return(true);
            }

            string userHostAddress = System.Web.HttpContext.Current.Request.UserHostAddress;

            if (BLL.CallRecord_ORIG_Authorizer.Instance.IsExistsByIPAndCode(userHostAddress, Verifycode, status))
            {
                return(true);
            }
            else
            {
                msg = errorMsg + "userHostAddress=" + userHostAddress + ",Verifycode=" + Verifycode;
                return(false);
            }
        }
        private void LoginByPara()
        {
            string url = "login.aspx";

            if (!string.IsNullOrEmpty(DomainAccount) && !string.IsNullOrEmpty(Password))
            {
                string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                         organizationService);
                LoginResult loginResult = service.Login(DomainAccount, Password);
                if (loginResult == LoginResult.Success)
                {
                    int ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(DomainAccount);
                    if (ret > 0)
                    {
                        BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                        BLL.Util.LoginPassport(ret, sysID);
                        url = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")

                        DataTable dtParent = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(HttpContext.Current.Session["userid"]), sysID);
                        if (dtParent != null)
                        {
                            DataTable dtChild = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(HttpContext.Current.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                            if (dtChild.Rows.Count > 0)
                            {
                                url = dtChild.Rows[0]["url"].ToString();
                            }
                        }

                        ret = 1;//登陆成功
                        string content = string.Format("用户{1}(ID:{0})登录成功。", HttpContext.Current.Session["userid"], HttpContext.Current.Session["truename"]);
                        BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                    }
                }
                Response.Redirect(url);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.CustInfo == null)
                {
                    return;
                }
                this.CustID = this.CustInfo.CustID;
                //查询第一个经销商
                List <BitAuto.YanFa.Crm2009.Entities.DMSMember> list = BitAuto.YanFa.Crm2009.BLL.DMSMember.Instance.GetDMSMember(CustID);
                if (list != null && list.Count > 0)
                {
                    FirstMemberCode = list[0].MemberCode;
                    FirstMemberName = list[0].Name;
                }
                AddWorderv2Url = "/WOrderV2/AddWOrderInfo.aspx?" + BLL.WOrderRequest.AddWOrderComeIn_CRMCustID(CustID).ToString();

                if (this.CustInfo.Officetel == "")
                {
                    AddWorderv2Url_Phone = "href='javascript:void(0)' ";
                }
                else
                {
                    AddWorderv2Url_Phone  = "href='/WOrderV2/AddWOrderInfo.aspx?" + BLL.WOrderRequest.AddWOrderComeIn_CallOut(this.CustInfo.Officetel, this.CustInfo.CustID, this.CustInfo.contactName, -1, FirstMemberCode, -1).ToString() + "' ";
                    AddWorderv2Url_Phone += "target='_blank'";
                }

                BindCustomerInfo();
                BindMemberList(this.CustInfo.CustID);
                SurveyListID.RequestCustID = this.CustID;
                string sysId  = ConfigurationUtil.GetAppSettingValue("ThisSysID");
                int    userId = BLL.Util.GetLoginUserID();
                AddReturnVistCustButton = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.CheckRight("SYS024BUT1410", sysId, userId);
            }
        }
        private static string Key = ConfigurationUtil.GetAppSettingValue("CarFinancial_GenURLParaMD5");//"@#$%^&*(";
        public void ProcessRequest(HttpContext context)
        {
            BitAuto.YanFa.SysRightManager.Common.UserInfo.Check();
            int userid = BLL.Util.GetLoginUserID();

            //userid = 167697; //测试账号
            context.Response.ContentType = "text/plain";
            string msg = string.Empty;

            try
            {
                string url = ConfigurationUtil.GetAppSettingValue("CarFinancial_URL");//"http://testcc.chedai.bitauto.com/Account/LogOn";
                // 加密字符串
                string enString = Encrypt(userid.ToString(), Key);
                msg = string.Format("{0}?u={1}&sign={2}", url, userid.ToString(), enString);
                msg = HttpUtility.UrlEncode(msg);
            }
            catch (Exception ex)
            {
                msg = "Error";
            }

            context.Response.Write(msg);
        }
        public bool subDate(out string msg)
        {
            bool result = false;

            msg = "";
            string log = "";

            #region 事务保存信息

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            //真实的数据操作
            try
            {
                if (examObj.EIID > 0)
                {//编辑
                    Entities.ExamInfo examObjOri = new Entities.ExamInfo();
                    examObjOri      = BLL.ExamInfo.Instance.GetExamInfo(examObj.EIID);
                    examObj.JoinNum = examPersionList.Count;
                    BLL.ExamInfo.Instance.Update(tran, examObj);
                    //先清除参考人员
                    BLL.ExamPerson.Instance.Delete(examObj.EIID);
                    foreach (Entities.ExamPerson examPersion in examPersionList)
                    {
                        examPersion.EIID = examObj.EIID;
                        try
                        {
                            BLL.ExamPerson.Instance.Insert(tran, examPersion);
                        }
                        catch (Exception ex)
                        {
                            msg = ex.Message.ToString().Replace("'", "");
                            msg = msg.Replace("\r\n", "");
                        }
                    }
                    //清除补考
                    BLL.MakeUpExamInfo.Instance.Delete(tran, (int)examObj.EIID);

                    if (examObj.IsMakeUp == 1)
                    {//添加新补考
                        makeExamOjb.JoinNum = makeExamPersionList.Count;
                        makeExamOjb.EIID    = examObj.EIID;
                        makeExamOjb.MEIID   = BLL.MakeUpExamInfo.Instance.Insert(tran, makeExamOjb);
                        foreach (Entities.ExamPerson examPersion in makeExamPersionList)
                        {
                            examPersion.MEIID = makeExamOjb.MEIID;
                            examPersion.EIID  = makeExamOjb.EIID;
                            try
                            {
                                BLL.ExamPerson.Instance.Insert(tran, examPersion);
                            }
                            catch (Exception ex)
                            {
                                msg = ex.Message.ToString().Replace("'", "");
                                msg = msg.Replace("\r\n", "");
                            }
                        }
                        log += ";补考信息更新为-补考MEIID:" + makeExamOjb.MEIID + ";开始时间:"
                               + makeExamOjb.MakeUpExamStartTime + ";结束时间:" + makeExamOjb.MakeupExamEndTime;
                    }
                }
                else
                {//添加
                    examObj.JoinNum = examPersionList.Count;
                    examObj.EIID    = BLL.ExamInfo.Instance.Insert(tran, examObj);

                    foreach (Entities.ExamPerson examPersion in examPersionList)
                    {
                        examPersion.EIID = examObj.EIID;
                        try {
                            BLL.ExamPerson.Instance.Insert(tran, examPersion);
                        }
                        catch (Exception ex)
                        {
                            msg = ex.Message.ToString().Replace("'", "");
                            msg = msg.Replace("\r\n", "");
                        }
                    }
                    log = "添加考试项目-EIID:" + examObj.EIID + ";标题:" + examObj.Name + ";考试说明:"
                          + examObj.Description + ";开始时间:" + examObj.ExamStartTime + ";结束时间:" + examObj.ExamEndTime;
                    if (examObj.IsMakeUp == 1)
                    {//补考
                        makeExamOjb.JoinNum = makeExamPersionList.Count;
                        makeExamOjb.EIID    = examObj.EIID;
                        makeExamOjb.MEIID   = BLL.MakeUpExamInfo.Instance.Insert(tran, makeExamOjb);
                        foreach (Entities.ExamPerson examPersion in makeExamPersionList)
                        {
                            examPersion.MEIID = makeExamOjb.MEIID;
                            examPersion.EIID  = makeExamOjb.EIID;
                            try
                            {
                                BLL.ExamPerson.Instance.Insert(tran, examPersion);
                            }
                            catch (Exception ex)
                            {
                                msg = ex.Message.ToString().Replace("'", "");
                                msg = msg.Replace("\r\n", "");
                            }
                        }
                        log += ";补考信息-补考MEIID:" + makeExamOjb.MEIID + ";开始时间:"
                               + makeExamOjb.MakeUpExamStartTime + ";结束时间:" + makeExamOjb.MakeupExamEndTime;
                    }
                }

                tran.Commit();
                //写入日志
                BLL.Util.InsertUserLog(log);
                result = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = ex.Message.ToString().Replace("'", "");
                msg = msg.Replace("\r\n", "");
            }
            finally
            {
                connection.Close();
            }
            return(result);

            #endregion
        }
        /// <summary>
        /// 生成任务
        /// </summary>
        /// <param name="dt"></param>
        public void GenTask(DataTable dt)
        {
            int taskCount  = 0;
            int existCount = 0;

            BLL.Loger.Log4Net.Info("生成_易湃_置换订单_开始:");
            DateTime  dtNow = DateTime.Now;
            DataTable dtNew = dt.Clone();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int YPOrderID = int.Parse(dt.Rows[i]["OrderBusinessOpportunityID"].ToString());
                int dealerID  = -1;
                int.TryParse(dt.Rows[i]["DealerID"].ToString(), out dealerID);
                if (BLL.OrderRelpaceCarLog.Instance.IsExistsByYPOrderID(YPOrderID))//存在
                {
                    BLL.Util.InsertUserLogNoUser("(置换)易湃订单ID:" + YPOrderID + "的记录已经存在,不在生成任务!");
                }
                else if (dealerID > 0)//Add=Masj,Date=2013-08-26,去掉免费订单的相关数据
                {
                    BLL.Loger.Log4Net.Info("(置换)易湃订单ID:" + YPOrderID + "的记录经销商为" + dealerID + "(免费订单),不生成任务!");
                }
                else//不存在
                {
                    dtNew.ImportRow(dt.Rows[i]);
                }
            }
            BLL.Loger.Log4Net.Info("检测拿到的置换订单数据中有" + existCount + "条数据在呼叫中心库中已经存在了");

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);

            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("OrderRelpaceCarLogTransaction");

            try
            {
                for (int i = 0; i < dtNew.Rows.Count; i++)
                {
                    Entities.OrderRelpaceCarLog model = InitOrderRelpaceCarLog(dtNew.Rows[i]);
                    if (model != null)
                    {
                        long OrderRelpaceCarLogID = Insert(tran, model); //插入OrderRelpaceCarLog表

                        if (model.CarID != Constant.INT_INVALID_VALUE && model.CarID != 0)
                        {
                            //Add By Chybin At 2013.2.13  如果Carid和OrderQuantity为空,就只插入OrderRelpaceCarLog 表,不生成任务,不插入OrderRelpaceCar 表
                            //Add By Masj At 2013.7.26 OrderQuantity为空去掉限制了
                            long taskID = BLL.OrderTask.Instance.InsertByOrder(tran, model);
                            if (BLL.OrderRelpaceCar.Instance.IsExistsByTaskID(taskID))
                            {
                                BLL.Util.InsertUserLogNoUser(tran, "(置换)任务ID" + taskID + "的记录已经存在,不在生成任务!");
                            }
                            else if (BLL.OrderRelpaceCar.Instance.InsertByTaskID(tran, taskID, model))
                            {
                                BLL.Util.InsertUserLogNoUser(tran, "(置换)任务ID" + taskID + "的记录生成成功!"); taskCount++;
                            }
                        }
                    }
                }
                //事务提交
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                string msg = "(置换)生成任务失败!失败原因:" + ex.Message;
                BLL.Util.InsertUserLogNoUser(msg);
                BLL.Loger.Log4Net.Error(msg, ex);
            }
            finally
            {
                connection.Close();
            }
            string msgTitle = "一共生成(置换)任务:" + taskCount + "个";

            BLL.Util.InsertUserLogNoUser(msgTitle);
            BLL.Loger.Log4Net.Error(msgTitle);
            TimeSpan ts = new TimeSpan();

            ts = DateTime.Now - dtNow;
            BLL.Loger.Log4Net.Info("生成_易湃_置换订单_结束:" + msgTitle + ",用时" + ts.TotalSeconds + "秒。");
        }
        //提交或保存:type=submit 提交;type=save 保存
        public void examOnlineOperate(string type, out string msg)
        {
            msg = string.Empty;


            int  loginerID   = BLL.Util.GetLoginUserID(); //登陆者ID
            int  _EOLID      = 0;                         //插入该考生在线考试记录后返回的主键
            int  _EOLDID     = 0;                         //插入在线考试小题明细记录后返回的主键
            int  _totalScore = 0;                         //记录总得分,最后一步更新到在线考试表中
            bool isSubject   = false;                     //是否存在主观题,默认false 不存在(在线考试试卷则为已阅);true存在(在线考试试卷则为未阅)
            int  _paperID;                                //试卷ID

            if (!int.TryParse(RequestExamPaperID, out _paperID))
            {
                msg = "{msg:'试卷ID出错,操作失败!'}";
                return;
            }
            Entities.ExamOnline model_examOnlineInsert       = null;            //新增时增加的在线考试实体,如果之前没保存过,则需要新增
            Entities.ExamOnline model_examOnlineToUpdate     = null;            //需要修改之前保存过的试卷信息
            ArrayList           array_examOnlineDetailDelete = new ArrayList(); //如果有过保存的记录,则保存需要删除的小题明细ID 集合
            ArrayList           array_examOnlineAnswerDelete = new ArrayList(); //如果有过保存的记录,则保存需要删除的答案ID 集合
            bool paperIsSave = false;                                           //该考生试卷是否被保存过,false 没有;true 是;

            ArrayList array_appendValueAnswer = new ArrayList();                //记录答案对应的小题明细数组
            int       examOnlineDetailIndex   = 0;                              //数组值

            int _EIID;

            if (!int.TryParse(RequestEIID, out _EIID))
            {
                msg = "{msg:'项目ID出错,操作失败!'}";
                return;
            }

            judgeSubmitExamLimit(_EIID, out msg);
            if (msg != string.Empty)
            {
                return;
            }

            //在线考试明细表 集合(非主观题)
            List <Entities.ExamOnlineDetail> list_examOnlineDetail = new List <Entities.ExamOnlineDetail>();
            //在线考试答案表 集合(非主观题)
            List <Entities.ExamOnlineAnswer> list_examOnlineAnswer = new List <Entities.ExamOnlineAnswer>();

            //在线考试明细表 集合(主观题)
            List <Entities.ExamOnlineDetail> list_SubjetExamOnlineDetail = new List <Entities.ExamOnlineDetail>();
            //在线考试答案表 集合(主观题)
            List <Entities.ExamOnlineAnswer> list_SubjetExamOnlineAnswer = new List <Entities.ExamOnlineAnswer>();

            //日志:修改 在线考试表 集合
            ArrayList array_updateExamOnlineLog = new ArrayList();

            //在线考试表 修改前的model
            Entities.ExamOnline model_updateExamOnlineLog_Old = null;
            //日志:插入 在线考试表 集合
            ArrayList arry_insertExamOnlineLog = new ArrayList();
            //日志:插入 在线考试明细表 记录集合
            ArrayList array_insertExamOnlineDetailLog = new ArrayList();
            //日志:插入 在线考试答案表 记录集合
            ArrayList array_insertExamOnlineAnswerLog = new ArrayList();



            #region 准备数据

            Entities.QueryExamOnline query_examOnlineSave = new Entities.QueryExamOnline();
            int saveCount;
            if (RequestExamType == "1")    //补考项目考试
            {
                query_examOnlineSave.MEIID    = _EIID;
                query_examOnlineSave.IsMakeUp = 1;
            }
            else if (RequestExamType == "0")    //正常项目考试
            {
                query_examOnlineSave.IsMakeUp = 0;
                query_examOnlineSave.EIID     = _EIID;
            }
            query_examOnlineSave.ExamPersonID = loginerID;
            DataTable dt_examOnlineSave = BLL.ExamOnline.Instance.GetExamOnline(query_examOnlineSave, "", 1, 10000, out saveCount);
            if (dt_examOnlineSave.Rows.Count > 0)
            {
                paperIsSave = true;
                //存在数据,准备上次保存的数据,对其进行修改
                model_examOnlineToUpdate      = BLL.ExamOnline.Instance.GetExamOnline(long.Parse(dt_examOnlineSave.Rows[0]["EOLID"].ToString()));
                model_updateExamOnlineLog_Old = model_examOnlineToUpdate;
                if (model_examOnlineToUpdate != null)
                {
                    model_examOnlineToUpdate.ExamEndTime = DateTime.Now;
                    model_examOnlineToUpdate.IsLack      = 0;
                    //准备需要删除的小题明细ID 集合
                    Entities.QueryExamOnlineDetail query_examOnlineDetailDelete = new Entities.QueryExamOnlineDetail();
                    query_examOnlineDetailDelete.EOLID = int.Parse(model_examOnlineToUpdate.EOLID.ToString());
                    DataTable dt_detailDelete = BLL.ExamOnlineDetail.Instance.GetExamOnlineDetail(query_examOnlineDetailDelete, "", 1, 10000, out saveCount);
                    for (int i = 0; i < dt_detailDelete.Rows.Count; i++)
                    {
                        //插入 集合
                        array_examOnlineDetailDelete.Add(dt_detailDelete.Rows[i]["EOLDID"].ToString());
                        //准备需要删除的该小题答案ID 集合
                        Entities.QueryExamOnlineAnswer query_examOnlineAnswerDelete = new Entities.QueryExamOnlineAnswer();
                        query_examOnlineAnswerDelete.EOLDID = int.Parse(dt_detailDelete.Rows[i]["EOLDID"].ToString());
                        DataTable dt_answerDelete = BLL.ExamOnlineAnswer.Instance.GetExamOnlineAnswer(query_examOnlineAnswerDelete, "", 1, 10000, out saveCount);
                        for (int j = 0; j < dt_answerDelete.Rows.Count; j++)
                        {
                            //插入 集合
                            array_examOnlineAnswerDelete.Add(dt_answerDelete.Rows[j]["RecID"].ToString());
                        }
                    }
                }
            }

            //  a、准备 插入在线考试表记录 数据

            //  如果之前保存过数据,则不需要新增,修改即可
            if (paperIsSave == false)
            {
                model_examOnlineInsert = new Entities.ExamOnline();
                if (RequestExamType == "1")    //补考项目考试
                {
                    model_examOnlineInsert.IsMakeUp = 1;
                    model_examOnlineInsert.MEIID    = _EIID;
                    //根据补考项目ID,找到对应的考试项目ID,并赋值
                    Entities.MakeUpExamInfo model_makeUpExamInfoGetEIID = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfo(_EIID);
                    if (model_makeUpExamInfoGetEIID == null)
                    {
                        msg = "{msg:'该补考项目对应考试项目ID未找到,操作失败!'}";
                        return;
                    }
                    model_examOnlineInsert.EIID = int.Parse(model_makeUpExamInfoGetEIID.EIID.ToString());
                }
                else if (RequestExamType == "0")    //正常项目考试
                {
                    model_examOnlineInsert.IsMakeUp = 0;
                    model_examOnlineInsert.EIID     = _EIID;
                }
                model_examOnlineInsert.ExamPersonID  = loginerID;
                model_examOnlineInsert.ExamStartTime = DateTime.Parse(RequestExamStartTime);
                model_examOnlineInsert.ExamEndTime   = DateTime.Now;
                model_examOnlineInsert.CreateTime    = DateTime.Now;
                model_examOnlineInsert.CreaetUserID  = loginerID;
                model_examOnlineInsert.IsLack        = 0; //不算缺考

                //_EOLID = insertExamOnline(tran, model_examOnlineInsert);
            }
            if (model_examOnlineInsert != null)
            {
                model_examOnlineInsert.Status = type == "save" ? 0 : 1;
            }
            if (model_examOnlineToUpdate != null)
            {
                model_examOnlineToUpdate.Status = type == "save" ? 0 : 1;
            }

            #endregion

            #region b、准备 插入在线考试小题明细 数据

            #region 1)准备 非主观题 数据
            if (RequestNoSubjectQestion != "")
            {
                //分解成每一个小题数组,类似['大题ID:小题ID:单选题答案','大题ID:小题ID:复选题答案1;复选题答案2;复选题答案3']
                string[] noSubjectQuestion = RequestNoSubjectQestion.Split(',');
                for (int i = 0; i < noSubjectQuestion.Length; i++)
                {
                    examOnlineDetailIndex = i;
                    //分解成每一个小题详细信息的数组,类似['大题ID','小题ID','复选题答案1;复选题答案2;复选题答案3']
                    string[] eachNoSubjectQuestion = noSubjectQuestion[i].Split(':');
                    //如果该小题的详细信息都有值,则插入;否则,不插入
                    if (eachNoSubjectQuestion[0] != "" && eachNoSubjectQuestion[1] != "" && eachNoSubjectQuestion[2] != "")
                    {
                        Entities.ExamOnlineDetail model_examOnlineDetailInsert = new Entities.ExamOnlineDetail();
                        //model_examOnlineDetailInsert.EOLID = int.Parse(_EOLID.ToString());
                        model_examOnlineDetailInsert.EPID  = _paperID;
                        model_examOnlineDetailInsert.BQID  = long.Parse(eachNoSubjectQuestion[0]);
                        model_examOnlineDetailInsert.KLQID = long.Parse(eachNoSubjectQuestion[1]);
                        model_examOnlineDetailInsert.Score = 0;

                        //  (1)根据该生给出的答案去比较正确的答案
                        //  先根据该小题ID去找出该题正确答案串
                        string rightAnswer = string.Empty;
                        Entities.QueryKLQAnswer query_KLQAnswer = new Entities.QueryKLQAnswer();
                        int totalCount;
                        query_KLQAnswer.KLQID = model_examOnlineDetailInsert.KLQID;
                        DataTable dt_KLQAnswer = BLL.KLQAnswer.Instance.GetKLQAnswer(query_KLQAnswer, "", 1, 10000, out totalCount);
                        if (dt_KLQAnswer.Rows.Count == 0)
                        {
                            msg = "{msg:'对应题目的答案未找到,操作失败!'}";
                            return;
                        }
                        for (int j = 0; j < dt_KLQAnswer.Rows.Count; j++)
                        {
                            rightAnswer += dt_KLQAnswer.Rows[j]["KLAOID"].ToString() + ";";
                        }
                        rightAnswer = rightAnswer.TrimEnd(';');

                        //  比较该串与考生给出的答案串是否相同,相同则得分;不相同给零分
                        //  比较方法(两个长度相同,分解考生答案,保证每一个答案都在正确答案内)
                        if (eachNoSubjectQuestion[2].Length == rightAnswer.Length)
                        {
                            string[] eachNoSubjectAnswer = eachNoSubjectQuestion[2].Split(';');
                            bool     IsRightOrWrong      = true; //  答案是否正确,正确true;错误false
                            for (int ea = 0; ea < eachNoSubjectAnswer.Length; ea++)
                            {
                                if (!rightAnswer.Contains(eachNoSubjectAnswer[ea]))
                                {
                                    IsRightOrWrong = false;
                                }
                            }
                            if (IsRightOrWrong)
                            {
                                //  (2)找到该小题如果正确则应得的分数
                                Entities.ExamBigQuestion model_examBigQuestion = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(model_examOnlineDetailInsert.BQID);
                                if (model_examBigQuestion == null)
                                {
                                    msg = "{msg:'对应该小题的对应的分数未找到,操作失败!'}";
                                    return;
                                }
                                int eachQuestionScore = model_examBigQuestion.EachQuestionScore;
                                model_examOnlineDetailInsert.Score = eachQuestionScore;
                                _totalScore += eachQuestionScore;   //计入总得分
                            }
                        }
                        model_examOnlineDetailInsert.CreaetUserID = loginerID;
                        model_examOnlineDetailInsert.CreateTime   = DateTime.Now;
                        //插入在线考试小题明细表 集合
                        list_examOnlineDetail.Add(model_examOnlineDetailInsert);
                        //插入在线考试小题明细表 日志集合
                        string detailsLog = "在线考试小题明细表【插入】";
                        int    epidLog;
                        int    bqidLog;
                        int    klqidLog;
                        if (int.TryParse(model_examOnlineDetailInsert.EPID.ToString(), out epidLog))
                        {
                            Entities.ExamPaper model_examPaperLog = BLL.ExamPaper.Instance.GetExamPaper(epidLog);
                            if (model_examPaperLog != null)
                            {
                                detailsLog += "试卷名称【" + model_examPaperLog.Name + "】";
                            }
                        }
                        if (int.TryParse(model_examOnlineDetailInsert.BQID.ToString(), out bqidLog))
                        {
                            Entities.ExamBigQuestion model_examBigQuestionLog = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(bqidLog);
                            if (model_examBigQuestionLog != null)
                            {
                                detailsLog += "大题名称【" + model_examBigQuestionLog.Name + "】";
                            }
                        }
                        if (int.TryParse(model_examOnlineDetailInsert.KLQID.ToString(), out klqidLog))
                        {
                            Entities.KLQuestion model_klqQestionLog = BLL.KLQuestion.Instance.GetKLQuestion(klqidLog);
                            if (model_klqQestionLog != null)
                            {
                                detailsLog += "小题内容【" + model_klqQestionLog.Ask + "】";
                            }
                        }
                        detailsLog += "本小题得分【" + model_examOnlineDetailInsert.Score + "】插入时间【" + model_examOnlineDetailInsert.CreateTime + "】的记录";
                        array_insertExamOnlineDetailLog.Add(detailsLog);

                        //  (3)插入在线考试答案表
                        //  分解答案串,分条插入该表
                        string[] eachAnswer = eachNoSubjectQuestion[2].Split(';');
                        for (int k = 0; k < eachAnswer.Length; k++)
                        {
                            Entities.ExamOnlineAnswer model_examOnlineAnswer = new Entities.ExamOnlineAnswer();
                            //model_examOnlineAnswer.EOLDID = int.Parse(_EOLDID.ToString());
                            model_examOnlineAnswer.ExamAnswer   = eachAnswer[k];
                            model_examOnlineAnswer.CreaetUserID = loginerID;
                            model_examOnlineAnswer.CreateTime   = DateTime.Now;
                            //插入在线考试答案表 集合
                            list_examOnlineAnswer.Add(model_examOnlineAnswer);

                            array_appendValueAnswer.Add(examOnlineDetailIndex);

                            //插入在线考试答案表 日志集合
                            array_insertExamOnlineAnswerLog.Add("在线考试答案表【插入】提交答案:【" + model_examOnlineAnswer.ExamAnswer + "】插入时间【" + model_examOnlineAnswer.CreateTime + "】的记录");
                        }
                    }
                }
            }

            #endregion

            #region 2)准备 插入主观题 数据(主观题答案为空,也会插入)

            if (RequestSubjectQuestion != "")
            {
                //分解成每一个小题数组,类似['大题ID^^小题ID^^答案','大题ID^^小题ID^^答案','大题ID^^小题ID^^答案']
                string[] subjectQuestion = RequestSubjectQuestion.Split(new string[] { "$$" }, StringSplitOptions.None);
                for (int i = 0; i < subjectQuestion.Length; i++)
                {
                    //分解成每一题的每个详细信息,类似['大题ID','小题ID','答案']
                    string[] eachSubjectQuestion = subjectQuestion[i].Split(new string[] { "^^" }, StringSplitOptions.None);
                    Entities.ExamOnlineDetail model_subjectExamOnlineDetail = new Entities.ExamOnlineDetail();
                    //model_subjectExamOnlineDetail.EOLID = _EOLID.ToString;
                    model_subjectExamOnlineDetail.EPID         = _paperID;
                    model_subjectExamOnlineDetail.BQID         = long.Parse(eachSubjectQuestion[0]);
                    model_subjectExamOnlineDetail.KLQID        = long.Parse(eachSubjectQuestion[1]);
                    model_subjectExamOnlineDetail.Score        = 0;
                    model_subjectExamOnlineDetail.CreaetUserID = loginerID;
                    model_subjectExamOnlineDetail.CreateTime   = DateTime.Now;
                    //插入在线考试小题明细表 集合
                    list_SubjetExamOnlineDetail.Add(model_subjectExamOnlineDetail);
                    //插入在线考试小题明细表 日志集合
                    string detailsLog = "在线考试小题明细表【主观题】【插入】";
                    int    epidLog;
                    int    bqidLog;
                    int    klqidLog;
                    if (int.TryParse(model_subjectExamOnlineDetail.EPID.ToString(), out epidLog))
                    {
                        Entities.ExamPaper model_examPaperLog = BLL.ExamPaper.Instance.GetExamPaper(epidLog);
                        if (model_examPaperLog != null)
                        {
                            detailsLog += "试卷名称【" + model_examPaperLog.Name + "】";
                        }
                    }
                    if (int.TryParse(model_subjectExamOnlineDetail.BQID.ToString(), out bqidLog))
                    {
                        Entities.ExamBigQuestion model_examBigQuestionLog = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(bqidLog);
                        if (model_examBigQuestionLog != null)
                        {
                            detailsLog += "大题名称【" + model_examBigQuestionLog.Name + "】";
                        }
                    }
                    if (int.TryParse(model_subjectExamOnlineDetail.KLQID.ToString(), out klqidLog))
                    {
                        Entities.KLQuestion model_klqQestionLog = BLL.KLQuestion.Instance.GetKLQuestion(klqidLog);
                        if (model_klqQestionLog != null)
                        {
                            detailsLog += "小题内容【" + model_klqQestionLog.Ask + "】";
                        }
                    }
                    detailsLog += "本小题得分【" + model_subjectExamOnlineDetail.Score + "】插入时间【" + model_subjectExamOnlineDetail.CreateTime + "】的记录";
                    array_insertExamOnlineDetailLog.Add(detailsLog);

                    //在线考试答案表 实体
                    Entities.ExamOnlineAnswer model_subjectExamOnlineAnswer = new Entities.ExamOnlineAnswer();
                    //model_subjectExamOnlineAnswer.EOLDID = _EOLDID;
                    model_subjectExamOnlineAnswer.ExamAnswer   = eachSubjectQuestion[2];
                    model_subjectExamOnlineAnswer.CreaetUserID = loginerID;
                    model_subjectExamOnlineAnswer.CreateTime   = DateTime.Now;
                    //插入在线考试答案表 集合
                    list_SubjetExamOnlineAnswer.Add(model_subjectExamOnlineAnswer);

                    //插入在线考试答案表 日志集合
                    array_insertExamOnlineAnswerLog.Add("在线考试答案表【插入】提交答案:【" + model_subjectExamOnlineAnswer.ExamAnswer + "】插入时间【" + model_subjectExamOnlineAnswer.CreateTime + "】的记录");

                    //将isSubject字段修改为 true;在线考试的IsMarking需修改为0未阅
                    isSubject = true;
                }
            }

            if (model_examOnlineInsert != null)
            {
                model_examOnlineInsert.SumScore  = _totalScore;
                model_examOnlineInsert.IsMarking = isSubject == false ? 1 : 0;

                //准备插入数据的日志
                string logStr = string.Empty;
                if (type == "save")
                {
                    logStr += "【保存】";
                }
                else
                {
                    logStr += "【提交】";
                }
                logStr += "在线考试表【插入】";
                string meiidStr  = model_examOnlineInsert.IsMakeUp == 1 ? "补考项目ID【" + model_examOnlineInsert.MEIID + "】" : "";
                string isMakeUp  = model_examOnlineInsert.IsMakeUp == 1 ? "补考" : "未补考";
                string isMakeing = model_examOnlineInsert.IsMarking == 1 ? "已阅" : "未阅";
                string status    = model_examOnlineInsert.Status == 1 ? "提交" : "保存";
                //考试项目名称
                string            eiidName       = string.Empty;
                Entities.ExamInfo model_examInfo = BLL.ExamInfo.Instance.GetExamInfo(model_examOnlineInsert.EIID);
                if (model_examInfo != null)
                {
                    eiidName = model_examInfo.Name;
                    logStr  += "考试项目名称【" + eiidName + "】";
                }
                logStr += meiidStr + "考生名称【" + BLL.Util.GetNameInHRLimitEID(loginerID) + "】考试开始时间【"
                          + model_examOnlineInsert.ExamStartTime + "】考试结束时间【"
                          + model_examOnlineInsert.ExamEndTime + "】总得分【"
                          + model_examOnlineInsert.SumScore + "】是否补考【"
                          + isMakeUp + "】是否阅卷【" + isMakeing + "】状态【" + status + "】的记录";

                arry_insertExamOnlineLog.Add(logStr);
            }
            if (model_examOnlineToUpdate != null)
            {
                model_examOnlineToUpdate.SumScore  = _totalScore;
                model_examOnlineToUpdate.IsMarking = isSubject == false ? 1 : 0;

                //准备修改数据的日志
                string logStr = string.Empty;
                if (type == "save")
                {
                    logStr += "【保存】";
                }
                else
                {
                    logStr += "【提交】";
                }
                logStr += "在线考试表【更新】";
                if (model_updateExamOnlineLog_Old.SumScore != model_examOnlineToUpdate.SumScore)
                {
                    logStr += "总得分从【" + model_updateExamOnlineLog_Old.SumScore + "】修改成【" + model_examOnlineToUpdate.SumScore + "】";
                }
                if (model_updateExamOnlineLog_Old.IsMarking != model_examOnlineToUpdate.IsMarking)
                {
                    string isMarking_Old = model_updateExamOnlineLog_Old.IsMarking == 1 ? "是" : "否";
                    string isMarking_Now = model_examOnlineToUpdate.IsMarking == 1 ? "是" : "否";
                    logStr += "是否阅卷从【" + isMarking_Old + "】修改成【" + isMarking_Now + "】";
                }
                if (model_updateExamOnlineLog_Old.ExamEndTime != model_examOnlineToUpdate.ExamEndTime)
                {
                    logStr += "考试结束时间从【" + model_updateExamOnlineLog_Old.ExamEndTime + "】修改成【" + model_examOnlineToUpdate.ExamEndTime + "】";
                }
                if (model_updateExamOnlineLog_Old.Status != model_examOnlineToUpdate.Status)
                {
                    string status_Old = model_updateExamOnlineLog_Old.Status == 1 ? "提交" : "保存";
                    string status_Now = model_examOnlineToUpdate.Status == 1 ? "提交" : "保存";
                    logStr += "考生试卷状态从【" + status_Old + "】修改成【" + status_Now + "】";
                }
                logStr += "记录";
                array_updateExamOnlineLog.Add(logStr);
            }

            #endregion

            #endregion

            #region 提交、保存 实务操作

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");
            try
            {
                //如果没有保存过的,新增一条;如果被保存过,修改在线考试这条记录并删除之前的小题明细和答案,然后重新插入,反之都要插入
                if (paperIsSave == false)
                {
                    //插入在线考试表一条记录 _EOLID得到返回的主键值
                    _EOLID = insertExamOnline(tran, model_examOnlineInsert);
                }
                else
                {
                    _EOLID = int.Parse(model_examOnlineToUpdate.EOLID.ToString());

                    //修改在线考试表的该条记录
                    updateExamOnline(tran, model_examOnlineToUpdate);
                    //删除明细表的该考生本张试卷ID的所有明细记录
                    for (int i = 0; i < array_examOnlineDetailDelete.Count; i++)
                    {
                        long eoldid = long.Parse(array_examOnlineDetailDelete[i].ToString());
                        BLL.ExamOnlineDetail.Instance.Delete(tran, eoldid);
                        BLL.Util.InsertUserLog(tran, "在线考试明细表【删除】主键ID:【" + eoldid + "】的记录");
                    }
                    //删除答案表的该考生本张试卷ID的所有答案记录
                    for (int j = 0; j < array_examOnlineAnswerDelete.Count; j++)
                    {
                        long recid = long.Parse(array_examOnlineAnswerDelete[j].ToString());
                        BLL.ExamOnlineAnswer.Instance.Delete(tran, recid);
                        BLL.Util.InsertUserLog(tran, "在线考试答案表【删除】主键ID:【" + recid + "】的记录");
                    }
                }

                //插入非主观题
                for (int kk = 0; kk < list_examOnlineDetail.Count; kk++)
                {
                    //插入在线考试小题明细表 _EOLDID到返回的主键值
                    Entities.ExamOnlineDetail eachExamOnlineDetail = list_examOnlineDetail[kk];
                    eachExamOnlineDetail.EOLID = _EOLID;
                    _EOLDID = insertOnlineDetail(tran, eachExamOnlineDetail);

                    //插入在线考试答案表  这两个表的插入不一定是一对,因为有的是多选,需要多条插入
                    for (int n = kk; n < array_appendValueAnswer.Count; n++)
                    {
                        if (kk == int.Parse(array_appendValueAnswer[n].ToString()))
                        {
                            Entities.ExamOnlineAnswer eachExamOnlineAnswer = list_examOnlineAnswer[n];
                            eachExamOnlineAnswer.EOLDID = _EOLDID;
                            insertExamOnlineAnswer(tran, eachExamOnlineAnswer);
                        }
                    }
                }

                //插入主观题
                for (int tt = 0; tt < list_SubjetExamOnlineDetail.Count; tt++)
                {
                    //插入在线考试小题明细表 _EOLDID到返回的主键值
                    Entities.ExamOnlineDetail eachExamOnlineDetail = list_SubjetExamOnlineDetail[tt];
                    eachExamOnlineDetail.EOLID = _EOLID;
                    _EOLDID = int.Parse(insertOnlineDetail(tran, eachExamOnlineDetail).ToString());

                    //插入在线考试答案表 这两个表的插入肯定是一对,所以不用循环list
                    Entities.ExamOnlineAnswer eachExamOnlineAnswer = list_SubjetExamOnlineAnswer[tt];
                    eachExamOnlineAnswer.EOLDID = _EOLDID;
                    insertExamOnlineAnswer(tran, eachExamOnlineAnswer);
                }

                //插入日志
                for (int log1 = 0; log1 < arry_insertExamOnlineLog.Count; log1++)
                {
                    BLL.Util.InsertUserLog(tran, arry_insertExamOnlineLog[log1].ToString());
                }
                for (int log2 = 0; log2 < array_updateExamOnlineLog.Count; log2++)
                {
                    BLL.Util.InsertUserLog(tran, array_updateExamOnlineLog[log2].ToString());
                }
                for (int log3 = 0; log3 < array_insertExamOnlineDetailLog.Count; log3++)
                {
                    BLL.Util.InsertUserLog(tran, array_insertExamOnlineDetailLog[log3].ToString());
                }
                for (int log4 = 0; log4 < array_insertExamOnlineAnswerLog.Count; log4++)
                {
                    BLL.Util.InsertUserLog(tran, array_insertExamOnlineAnswerLog[log4].ToString());
                }

                //事务提交
                tran.Commit();

                msg = "{msg:'true'}";
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = "{msg:'" + ex.Message.ToString() + "'}";
                BLL.Loger.Log4Net.Error("在线考试异常", ex);
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }
Beispiel #12
0
        public DataTable GetWorkOrderInfoHMC(string Verifycode, QueryWorkOrderInfo query, int currentPage, out int totalCount, ref string msg)
        {
            string starttime = query.BeginCreateTime;
            string endtime   = query.EndCreateTime;

            BLL.Loger.Log4Net.Info("[CCDataInterfaceService.asmx]WorkOrderInfoExportHMC ...BEGIN...开始时间:" + starttime + ",结束时间:" + endtime);
            totalCount = 0;
            int pageSize = 20;

            string spageSize = ConfigurationUtil.GetAppSettingValue("CCInterfaceHMCPageSize");

            if (!string.IsNullOrEmpty(spageSize))
            {
                int itmp = 0;
                if (Int32.TryParse(spageSize, out itmp))
                {
                    pageSize = itmp;
                }
            }

            //验证授权码
            string sVerify = "";

            sVerify = ConfigurationUtil.GetAppSettingValue("CallRecordAuthorizeCode");
            if (sVerify == Verifycode)
            {
            }
            else
            {
                msg = "授权码错误!!";
                return(null);
            }

            //验证开始、结束时间格式是否正确
            DateTime dt;

            if (!DateTime.TryParse(starttime, out dt))
            {
                msg = "开始时间格式不正确!!";
                return(null);
            }

            if (!DateTime.TryParse(endtime, out dt))
            {
                msg = "结束时间格式不正确!!";
                return(null);
            }

            DataTable mydt = null;

            try
            {
                mydt = BLL.WorkOrderInfo.Instance.WorkOrderInfoExportHMC(query, "woi.CreateTime DESC", currentPage, pageSize, out totalCount);
            }
            catch (Exception ex)
            {
                BLL.Loger.Log4Net.Info("[CCDataInterfaceService.asmx]WorkOrderInfoExportHMC ...获取数据操作出错!errorStackTrace:" + ex.StackTrace);
            }

            BLL.Loger.Log4Net.Info("[CCDataInterfaceService.asmx]WorkOrderInfoExportHMC ...获取数据操作结束!");
            return(mydt);
        }
Beispiel #13
0
        //问卷调查提交
        private void surveyAnswerSubmit(out string msg)
        {
            msg = string.Empty;
            judgeIsCorrect(out msg);
            if (msg != "success")
            {
                return;
            }

            #region 提交准备数据

            SurveyAnswerRoot             modelRoot          = null;
            List <Entities.SurveyAnswer> list_ESurveyAnswer = new List <Entities.SurveyAnswer>();
            ArrayList array_UserActionLog = new ArrayList();//日志

            modelRoot = (SurveyAnswerRoot)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(RequestJsonSurveyAnswer, typeof(SurveyAnswerRoot));
            if (modelRoot == null)
            {
                msg = "提交的问卷数据不存在";
                return;
            }

            for (int i = 0; i < modelRoot.DataRoot.Length; i++)
            {
                Entities.SurveyAnswer model = new Entities.SurveyAnswer();

                SurveyAnswer answer = modelRoot.DataRoot[i];
                int          _spiid;
                if (int.TryParse(RequestSPIID, out _spiid))
                {
                    model.SPIID = _spiid;
                }
                if (!string.IsNullOrEmpty(RequestPTID))
                {
                    model.PTID = RequestPTID;
                }
                int _siid;
                if (int.TryParse(RequestSIID, out _siid))
                {
                    model.SIID = _siid;
                }
                int _sqid;
                if (int.TryParse(answer.SQID, out _sqid))
                {
                    model.SQID = _sqid;
                }
                int _smrtid;
                if (int.TryParse(answer.SMRTID, out _smrtid))
                {
                    model.SMRTID = _smrtid;
                }
                int _smctid;
                if (int.TryParse(answer.SMCTID, out _smctid))
                {
                    model.SMCTID = _smctid;
                }
                int _soid;
                if (int.TryParse(answer.SOID, out _soid))
                {
                    model.SOID = _soid;
                }
                model.AnswerContent = answer.AnswerContent;
                model.CreateUserID  = userID;
                model.CreateTime    = DateTime.Now;

                list_ESurveyAnswer.Add(model);

                string logStr = string.Empty;
                logStr = "调查问卷回答信息表【插入】问卷调查项目ID【" + model.SPIID + "】调查问卷ID【" + model.SIID + "】调查问卷试题ID【" + model.SQID + "】提交人【" + model.CreateUserID + "】调查问卷矩阵行ID【" + model.SMRTID + "】矩阵列ID【" + model.SMCTID + "】调查问卷选项ID【" + model.SOID + "】回答内容【" + model.AnswerContent + "】创建时间【" + model.CreateTime + "】";

                array_UserActionLog.Add(logStr);
            }

            #endregion

            #region 事务提交

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");
            try
            {
                //删除之前的答案
                if (!string.IsNullOrEmpty(RequestPTID))
                {
                    int _siid1;
                    if (int.TryParse(RequestSIID, out _siid1))
                    {
                        BLL.SurveyAnswer.Instance.Delete(tran, _siid1, RequestPTID);
                    }
                }



                for (int i = 0; i < list_ESurveyAnswer.Count; i++)
                {
                    BLL.SurveyAnswer.Instance.Insert(tran, list_ESurveyAnswer[i]);
                }
                for (int i = 0; i < array_UserActionLog.Count; i++)
                {
                    BLL.Util.InsertUserLog(tran, array_UserActionLog[i].ToString());
                }

                //是否答过题,默认答没答过
                bool flag = false;
                if (list_ESurveyAnswer.Count == 0)
                {
                    flag = false;
                }
                else
                {
                    for (int i = 0; i < list_ESurveyAnswer.Count; i++)
                    {
                        if (list_ESurveyAnswer[i].SOID != -2 || list_ESurveyAnswer[i].AnswerContent != "" || list_ESurveyAnswer[i].SMCTID != -2 || list_ESurveyAnswer[i].SMRTID != -2)
                        {
                            flag = true;
                        }
                    }
                }
                //答过题记录
                if (flag == true)
                {
                    //判断该项目,该任务,该问卷,是否已有答问卷记录,没有插入
                    DataTable dt = null;
                    Entities.QueryProjectTask_SurveyAnswer querey = new Entities.QueryProjectTask_SurveyAnswer();
                    querey.PTID = RequestPTID;

                    int _projectID;
                    if (int.TryParse(RequestProjectID, out _projectID))
                    {
                    }
                    querey.ProjectID = _projectID;
                    int _siid;
                    if (int.TryParse(RequestSIID, out _siid))
                    {
                    }
                    querey.SIID = _siid;
                    //int rowcount = 0;
                    //dt = BLL.ProjectTask_SurveyAnswer.Instance.GetProjectTask_SurveyAnswer(tran, querey, "", 1, 1000000, out rowcount);
                    Entities.ProjectTask_SurveyAnswer getModel = BLL.ProjectTask_SurveyAnswer.Instance.GetProjectTask_SurveyAnswerByQuery(tran, querey);
                    if (getModel == null)
                    {
                        Entities.ProjectTask_SurveyAnswer model = new Entities.ProjectTask_SurveyAnswer();
                        model.ProjectID    = _projectID;
                        model.PTID         = RequestPTID;
                        model.SIID         = _siid;
                        model.CreateTime   = System.DateTime.Now;
                        model.CreateUserID = BLL.Util.GetLoginUserID();
                        model.Status       = RequestIsSub;
                        BLL.ProjectTask_SurveyAnswer.Instance.Insert(tran, model);
                    }
                    else
                    {
                        getModel.CreateTime = DateTime.Now;
                        getModel.Status     = RequestIsSub;
                        BLL.ProjectTask_SurveyAnswer.Instance.UpdateCreateTimeAndStatus(tran, getModel);
                    }
                }
                msg = "success";

                tran.Commit();
            }
            catch (Exception ex)
            {
                BitAuto.ISDC.CC2012.BLL.Loger.Log4Net.Error("[TakingAnSurveyHandler.ashx]surveyAnswerSubmit...任务ID:" + RequestPTID + ",事务提交阶段出错:", ex);
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }
        /// 批量修改处理逻辑
        /// <summary>
        /// 批量修改处理逻辑
        /// </summary>
        /// <param name="msg"></param>
        private void EmployeeAgentMutilOption(out string msg)
        {
            msg = "";
            try
            {
                string[] userids    = UserIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string   cc_sysid   = ConfigurationUtil.GetAppSettingValue("ThisSysID");
                string   im_sysid   = ConfigurationUtil.GetAppSettingValue("IMSysID");
                string[] role_ids   = UserRolesID.Split('_');
                string   cc_role_id = role_ids[0];
                string   im_role_id = role_ids[1];
                int      btype      = BLL.Util.GetMutilEnumDataValue <BusinessTypeEnum>(BusinessType);
                BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Start");
                //权限设置
                foreach (string key in userids)
                {
                    //批量清空权限
                    int userid = CommonFunction.ObjectToInteger(key);
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.DeleteUserRole(userid, cc_sysid);
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.DeleteUserRole(userid, im_sysid);

                    //批量设置权限
                    if ((btype & (int)BusinessTypeEnum.CC) == (int)BusinessTypeEnum.CC)
                    {
                        BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.InsertUserRole(userid, cc_sysid, cc_role_id);
                        BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step1.更新CC系统中[UserID=" + userid + "]的用户的角色ID为:" + cc_role_id);
                    }
                    if ((btype & (int)BusinessTypeEnum.IM) == (int)BusinessTypeEnum.IM)
                    {
                        BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.InsertUserRole(userid, im_sysid, im_role_id);
                        BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step1.更新IM系统中[UserID=" + userid + "]的用户的角色ID为:" + im_role_id);
                    }
                }
                //批量更新所属业务和所属分组
                string ids = string.Join(",", userids);
                BLL.EmployeeAgent.Instance.UpdateMutilEmployeeAgent(ids, btype, CommonFunction.ObjectToInteger(AtGroupID));
                BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step2.更新[UserID in (" + ids + ")]的用户的[BusinessType(所属业务)=" + btype + "],[BGID(所属分组)=" + AtGroupID + "]");
                foreach (string key in userids)
                {
                    int userid = CommonFunction.ObjectToInteger(key);
                    UpdateUserSkillGroupDataRightByUserID(userid, out msg);
                    string TrueNameAgentNum = BLL.EmployeeAgent.Instance.GetAgentNumberAndUserNameByUserId(userid);
                    if (!string.IsNullOrEmpty(TrueNameAgentNum))
                    {
                        string[] tnan = TrueNameAgentNum.Split(';');
                        if (tnan.Length == 2)
                        {
                            GetHeLiDataByUserNameAndAgentNum(tnan[0], tnan[1], out msg);
                        }
                        else
                        {
                            msg = "{'result':'failure','msg':'部分用户由于数据异常导致技能组数据未能传给合力厂商接口,请检查坐席的“用户名”和“工号”数据是否存在!'}";
                            BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step3.由于未能取到UserID=" + userid + "的用户的UserName或AgentNum的值,导致未能调用合力厂商的接口!");
                        }
                    }
                    else
                    {
                        msg = "{'result':'failure','msg':'部分用户由于数据异常导致技能组数据未能传给合力厂商接口,请检查坐席的“用户名”和“工号”数据是否存在!'}";
                        BLL.Loger.Log4Net.Info("【批量修改用户数据权限】Step3.由于未能取到UserID=" + userid + "的用户的UserName或AgentNum的值,导致未能调用合力厂商的接口!");
                    }
                }
                BLL.Loger.Log4Net.Info("【批量修改用户数据权限】End");
                if (msg == "")
                {
                    msg = "{'result':'success'}";
                }
            }
            catch (Exception ex)
            {
                msg = "{'result':'failure','msg':'" + ex.Message + "'}";
            }
        }
        public void DeleteMemberInfo()
        {
            int id = -1;

            if (MemberID != "")
            {
                if (int.TryParse(MemberID, out id))
                {
                    Entities.ProjectTask_DMSMember member = BLL.ProjectTask_DMSMember.Instance.GetProjectTask_DMSMember(id);
                    if (member != null)
                    {
                        BitAuto.YanFa.Crm2009.Entities.DMSMember dmsMember = BitAuto.YanFa.Crm2009.BLL.DMSMember.Instance.GetDMSMember(new Guid(member.OriginalDMSMemberID));
                        if (dmsMember != null)
                        {
                            if (dmsMember.SyncStatus == (int)BitAuto.YanFa.Crm2009.Entities.EnumDMSSyncStatus.Rejected)
                            {
                                BitAuto.YanFa.Crm2009.BLL.DMSMember.Instance.Delete(dmsMember.ID.ToString());
                                BLL.ProjectTask_DMSMember.Instance.ProjectTask_DMSMemberDelete(id);
                                string content = string.Format("为【{0}(ID:{1})】删除会员【{2}(ID:{3})】成功。", dmsMember.CustName, dmsMember.CustID,
                                                               dmsMember.Name, dmsMember.MemberCode);
                                BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("MemberLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Delete, content);
                            }
                            else
                            {
                                throw new Exception("只有打回的会员才能删除!");
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("会员ID无法转换为int类型");
                }
            }

            //车商通会员删除
            if (OriginalCSTRecID != string.Empty)
            {
                BitAuto.YanFa.Crm2009.Entities.CstMember cstMember = BitAuto.YanFa.Crm2009.BLL.CstMember.Instance.GetCstMemberModel(OriginalCSTRecID);
                int ID = BLL.ProjectTask_CSTMember.Instance.GetIDByCSTRecID(OriginalCSTRecID);
                if (cstMember != null)
                {
                    if (cstMember.SyncStatus == (int)BitAuto.YanFa.Crm2009.Entities.EnumCSTSyncStatus.Rejected)
                    {
                        BitAuto.YanFa.Crm2009.BLL.CstMember.Instance.Delete(cstMember.ID.ToString()); //删除CRM车商通会员信息
                        BLL.ProjectTask_CSTMember.Instance.ProjectTask_CSTMemberDelete(ID);           //删除CC车商通会员信息
                        string content = string.Format("为【{0}(ID:{1})】删除会员【{2}(ID:{3})】成功。", cstMember.CustName, cstMember.CustID,
                                                       cstMember.FullName, cstMember.VendorCode);
                        BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("MemberLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Delete, content);
                    }
                    else
                    {
                        throw new Exception("只有打回的会员才能删除!");
                    }
                }
                else
                {
                    throw new Exception("删除失败");
                }
            }
        }
        //发送邮件 外部提交-根据固定的模板发送邮件
        private void sendEmail(string taskID, string templateID, int eid, string custID)
        {
            //url
            string urlHead = ConfigurationUtil.GetAppSettingValue("TaskProcessUrl");

            //找到邮件接收人的邮箱
            string userEmail = BLL.Util.GetEmployeeEmailByEid(eid);
            //1 插入 发送邮件日志表 (记录)
            SendEmailLog model_Email   = new SendEmailLog();
            string       templateName  = BLL.Util.GetEmployeeNameByEid(eid);//收件人姓名
            string       urlInternal   = urlHead + "/TaskManager/TaskProcess.aspx?TaskID=" + taskID;
            string       urlExternal   = urlHead + "/ExternalTask/ExternalTaskProcess.aspx?TaskID=" + taskID;
            string       templateTitle = string.Empty; //模板标题
            string       templateLog   = string.Empty; //模板日志
            string       templateUrl   = string.Empty; //模板链接格式
            int          _templateID;                  //模板ID

            //根据TaskID和受理人ID获取所要发送的模板ID
            if (int.TryParse(templateID, out _templateID))
            {
                QueryCustHistoryTemplateMapping query_Template = new QueryCustHistoryTemplateMapping();
                query_Template.TaskID       = taskID;
                query_Template.SolveUserEID = eid;
                int       count;
                DataTable dt_Template = BLL.CustHistoryTemplateMapping.Instance.GetCustHistoryTemplateMapping(query_Template, "", 1, 10000, out count);
                if (dt_Template != null)
                {
                    //根据模板ID获取模板内容
                    TemplateInfo model_TemplateInfo = new TemplateInfo();
                    model_TemplateInfo = BLL.TemplateInfo.Instance.GetTemplateInfo(_templateID);
                    if (model_TemplateInfo == null)
                    {
                        return;
                    }
                    //templateInfo += model_TemplateInfo.Content;
                    templateUrl  += model_TemplateInfo.Content + "<br/>";
                    templateTitle = model_TemplateInfo.Title;
                }
                templateLog += "【同意转出】";
            }
            else
            {
                _templateID  = 0;
                templateUrl += "呼叫中心系统有需要您协助处理的问题,";
                templateLog += "【提交】";
            }

            templateLog += "发出邮件至【" + userEmail + "】;接收人【" + templateName + "】";
            templateUrl += "详情请点击:<br/><a href='" + urlExternal + "'>" + urlHead + "/ExternalTask/ExternalTaskProcess.aspx</a><br/>";
            templateUrl += "呼叫中心系统内部人员请访问:<br/><a href='" + urlInternal + "'>" + urlHead + "/TaskManager/TaskProcess.aspx</a>";

            model_Email.TemplateID   = 0;
            model_Email.CustID       = custID;
            model_Email.MailTo       = userEmail;
            model_Email.SendTime     = DateTime.Now;
            model_Email.SendContent  = templateUrl;
            model_Email.CreateUserID = int.Parse(RequestLoginEID);

            BLL.SendEmailLog.Instance.Insert(model_Email);

            //2根据 客户历史记录信息表中 模板ID来发送模板邮件
            BLL.EmailHelper.Instance.SendMail(templateName, templateUrl, "呼叫中心问题处理", new string[] { userEmail });

            BLL.Util.InsertUserLog("【外部提交】发送邮件日志表【插入】客户名称:【" + BLL.CustBasicInfo.Instance.GetCustBasicInfo(model_Email.CustID).CustName + "】接收人:【" + templateName + "】邮箱:【" + model_Email.MailTo + "】发送内容:【" + model_Email.SendContent + "】的记录【邮件发送成功】", int.Parse(RequestLoginEID));
        }
        private void Submit(out string msg, int userID)
        {
            //此方法内的逻辑可参考文档:$/A5信息系统研发/销售业务管理平台/客户关系管理/doc/Call Center/无主订单处理页面保存和提交逻辑.docx  ---- Add By Chybin At 2013-07-19

            msg = "";

            //System.Threading.Thread.Sleep(5000);

            #region 准备数据

            NewCarConsultInfo              newInfo        = null;                       //新车订单信息
            ReplaceCarConsultInfo          replaceInfo    = null;                       //置换订单信息
            Entities.OrderTask             orderTaskModel = null;                       //无主订单任务信息
            Entities.OrderTaskOperationLog orderLog       = null;                       //任务操作日志
            List <StringBuilder>           listLogStr     = new List <StringBuilder>(); //用户操作日志
            StringBuilder sblogstr = new StringBuilder();
            string        logstr   = "";

            #region 取得新车/置换无主订单信息更新后Model(此时不保存到数据库)

            Entities.OrderNewCar     newModel     = null; //新车订单实体类
            Entities.OrderRelpaceCar replaceModel = null; //置换订单实体类

            if (Source == "1" || Source == "3")
            {
                newInfo = (NewCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(NewCarConsultInfoStr, typeof(NewCarConsultInfo));

                newModel = OrderNewSave.Save(newInfo, out msg, userID, int.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }
            else if (Source == "2")
            {
                replaceInfo  = (ReplaceCarConsultInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ReplaceCarConsultInfoStr, typeof(ReplaceCarConsultInfo));
                replaceModel = OrderReplaceSave.Save(replaceInfo, out msg, userID, long.Parse(TaskID));
                if (msg != "")
                {
                    return;
                }
            }

            #endregion

            #region 取得任务的更新后信息

            orderTaskModel = BLL.OrderTask.Instance.GetOrderTask(long.Parse(TaskID));
            if (orderTaskModel == null)
            {
                msg += "没有找到相关的任务信息";
                return;
            }

            if (orderTaskModel.TaskStatus != 2 && orderTaskModel.TaskStatus != 3)
            {
                msg += "当前任务状态不能保存和提交";
                return;
            }

            if (orderTaskModel.AssignUserID != userID)
            {
                msg += "此订单没有分配给你";
                return;
            }


            //修改状态
            if (Action == "save")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processing;
            }
            else if (Action == "sub")
            {
                orderTaskModel.TaskStatus = (int)TaskStatus.Processed;
                orderTaskModel.SubmitTime = DateTime.Now;
            }

            //是否已选择经销商 只有在提交时,才会改动该属性 -是否已选择经销商 lxw
            if (Action == "sub")
            {
                if (((Source == "1" || Source == "3") && newModel.DMSMemberCode != "") || (Source == "2" && replaceModel.DMSMemberCode != ""))
                {
                    orderTaskModel.IsSelectDMSMember = true;
                }
                else
                {
                    orderTaskModel.IsSelectDMSMember = false;
                }
            }

            if (Source == "1" || Source == "3")
            {
                orderTaskModel.UserName = newModel.UserName;
            }
            else if (Source == "2")
            {
                orderTaskModel.UserName = replaceModel.UserName;
            }

            if (NoDealerReasonID != "")
            {
                orderTaskModel.NoDealerReasonID = int.Parse(NoDealerReasonID);
            }
            orderTaskModel.NoDealerReason = NoDealerReason;


            #endregion

            #region 任务操作日志

            orderLog = new OrderTaskOperationLog();

            //modify by qizq 2013-1-4首先判断是否是通话中
            if (IsCalling == "1")
            {
                if (HistoryLogID == "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                }
            }
            //


            orderLog.TaskID = int.Parse(TaskID);

            if (Action == "save")
            {
                orderLog.OperationStatus = (int)OperationStatus.Save;
            }
            else if (Action == "sub")
            {
                orderLog.OperationStatus = (int)OperationStatus.Submit;
            }
            orderLog.TaskStatus   = orderTaskModel.TaskStatus;
            orderLog.CreateTime   = DateTime.Now;
            orderLog.CreateUserID = userID;

            #endregion

            #region 如果是提交操作,更新客户信息、插入咨询类型、添加客户联系记录

            Entities.CustBasicInfo          custmodel     = null;       //客户信息实体类
            Entities.CustTel                telPhoneMode  = null;       //电话实体类
            Entities.CustTel                telMobileMode = null;       //电话实体类
            Entities.CustEmail              emailMode     = null;       //邮件实体类
            Entities.ConsultOrderNewCar     cNewCar       = null;       //新车咨询类型
            Entities.ConsultOrderRelpaceCar cReplaceCar   = null;       //置换车咨询类型
            Entities.CustHistoryInfo        custHistInfo  = null;       //客户联系记录

            Entities.BuyCarInfo buyCarInfo = new Entities.BuyCarInfo(); //已购车或未购车信息 lxw

            if (Action == "sub")
            {
                #region 更新或插入客户信息
                //代码失效,功能废弃,需求重新实现
                #endregion

                #region 插入咨询类型

                if (Source == "1" || Source == "3")
                {
                    cNewCar = new ConsultOrderNewCar();

                    #region 赋值

                    cNewCar.CarBrandId   = newModel.CarMasterID;
                    cNewCar.CarSerialId  = newModel.CarSerialID;
                    cNewCar.CarNameID    = newModel.CarTypeID;
                    cNewCar.CarColor     = newModel.CarColor;
                    cNewCar.DealerCode   = newModel.DMSMemberCode;
                    cNewCar.DealerName   = newModel.DMSMemberName;
                    cNewCar.OrderRemark  = newModel.OrderRemark;
                    cNewCar.CallRecord   = newModel.CallRecord;
                    cNewCar.CreateTime   = DateTime.Now;
                    cNewCar.CreateUserID = userID;

                    #endregion
                }
                else if (Source == "2")
                {
                    cReplaceCar = new ConsultOrderRelpaceCar();

                    #region 赋值

                    cReplaceCar.WantBrandId        = replaceModel.RepCarMasterID;
                    cReplaceCar.WantSerialId       = replaceModel.RepCarSerialID;
                    cReplaceCar.WantNameID         = replaceModel.RepCarTypeId;
                    cReplaceCar.WantCarColor       = replaceModel.ReplacementCarColor;
                    cReplaceCar.WantDealerName     = replaceModel.DMSMemberName;
                    cReplaceCar.WantDealerCode     = replaceModel.DMSMemberCode;
                    cReplaceCar.CallRecord         = replaceModel.CallRecord;
                    cReplaceCar.OldBrandId         = replaceModel.CarMasterID;
                    cReplaceCar.OldSerialId        = replaceModel.CarSerialID;
                    cReplaceCar.OldNameID          = replaceModel.CarTypeID;
                    cReplaceCar.OldCarColor        = replaceModel.CarColor;
                    cReplaceCar.RegisterDateYear   = replaceModel.ReplacementCarBuyYear.ToString();
                    cReplaceCar.RegisterDateMonth  = replaceModel.ReplacementCarBuyMonth.ToString();
                    cReplaceCar.RegisterProvinceID = replaceModel.RepCarProvinceID;
                    cReplaceCar.RegisterCityID     = replaceModel.RepCarCityID;
                    cReplaceCar.RegisterCountyID   = replaceModel.RepCarCountyID;
                    cReplaceCar.Mileage            = (decimal)replaceModel.ReplacementCarUsedMiles;
                    cReplaceCar.PresellPrice       = replaceModel.SalePrice;
                    cReplaceCar.OrderRemark        = replaceModel.OrderRemark;
                    cReplaceCar.CreateTime         = DateTime.Now;
                    cReplaceCar.CreateUserID       = userID;

                    #endregion
                }

                #endregion

                #region 插入客户历史记录

                custHistInfo = new CustHistoryInfo();

                #region 赋值

                custHistInfo.TaskID = TaskID;
                if (Source == "1" || Source == "3")
                {
                    custHistInfo.ConsultID = 60010;//新车咨询类型
                }
                else
                {
                    custHistInfo.ConsultID = 60011;//置换咨询类型
                }
                custHistInfo.RecordType        = 2;
                custHistInfo.QuestionQuality   = (int)QuestionNature.NatureCommon;
                custHistInfo.ProcessStatus     = (int)EnumTaskStatus.TaskStatusOver;
                custHistInfo.CreateTime        = DateTime.Now;
                custHistInfo.CreateUserID      = userID;
                custHistInfo.LastTreatmentTime = DateTime.Now;

                #endregion

                #endregion
            }

            #endregion

            #endregion

            #region 事务提交

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction(IsolationLevel.ReadUncommitted, "SampleTransaction");

            try
            {
                #region 保存新车/置换无主订单信息

                if (Source == "1" || Source == "3")
                {
                    BLL.OrderNewCar.Instance.Update(tran, newModel);
                }
                else if (Source == "2")
                {
                    BLL.OrderRelpaceCar.Instance.Update(tran, replaceModel);
                }

                #endregion

                #region 修改任务信息

                BLL.OrderTask.Instance.Update(tran, orderTaskModel);

                #endregion

                #region 任务操作日志

                //modify by qizq 2013-1-4不是在通话中,处理记录已存在更新处理记录
                if (IsCalling != "1" && HistoryLogID != "")
                {
                    //通话中提交把本地录音主键付给实体
                    long CallRecordReCID = 0;
                    if (CallRecordID != "")
                    {
                        if (long.TryParse(CallRecordID, out CallRecordReCID))
                        {
                            orderLog.CallRecordID = CallRecordReCID;
                        }
                    }
                    long HistoryLogIDLog = 0;
                    if (long.TryParse(HistoryLogID, out HistoryLogIDLog))
                    {
                        orderLog.RecID = HistoryLogIDLog;
                    }
                    BLL.OrderTaskOperationLog.Instance.Update(tran, orderLog);
                }
                else
                {
                    BLL.OrderTaskOperationLog.Instance.Insert(tran, orderLog);
                }
                //



                #endregion

                if (Action == "sub")
                {
                    string retCustID = "";

                    #region 更新或插入客户信息

                    if (custmodel.RecID == -2)
                    {
                        //新加的客户

                        retCustID = BLL.CustBasicInfo.Instance.Insert(tran, custmodel);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了客户‘" + custmodel.CustName + "’的信息【ID:" + retCustID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑客户信息
                        BLL.CustBasicInfo.Instance.Update(tran, custmodel);
                        retCustID = custmodel.CustID;
                    }
                    #endregion

                    #region 插入电话

                    if (telPhoneMode != null)
                    {
                        telPhoneMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telPhoneMode);
                    }

                    if (telMobileMode != null)
                    {
                        telMobileMode.CustID = retCustID;
                        BLL.CustTel.Instance.Insert(tran, telMobileMode);
                    }

                    #endregion

                    #region 插入邮箱

                    if (emailMode != null)
                    {
                        emailMode.CustID = retCustID;
                        BLL.CustEmail.Instance.Insert(tran, emailMode);
                    }

                    #endregion

                    #region 插入咨询类型

                    int retDataID = 0;

                    if (cNewCar != null)
                    {
                        cNewCar.CustID = retCustID;
                        retDataID      = BLL.ConsultOrderNewCar.Instance.Insert(tran, cNewCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单新车联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }
                    if (cReplaceCar != null)
                    {
                        cReplaceCar.CustID = retCustID;
                        retDataID          = BLL.ConsultOrderRelpaceCar.Instance.Insert(tran, cReplaceCar);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了无主订单置换联系咨询记录【ID:" + retDataID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入未购车或已购车记录 BuyCarInfo lxw

                    if (buyCarInfo != null && buyCarInfo.RecID == -2)
                    {
                        buyCarInfo.CustID = retCustID;
                        int recID = BLL.BuyCarInfo.Instance.Insert(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "新加了未购车已购车BuyCarInfo表的记录【ID:" + recID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    if (buyCarInfo != null && buyCarInfo.RecID != -2)
                    {
                        BLL.BuyCarInfo.Instance.Update(tran, buyCarInfo);

                        #region 记日志

                        sblogstr = new StringBuilder();
                        logstr   = "";
                        logstr  += "修改了未购车已购车BuyCarInfo表的记录【ID:" + buyCarInfo.RecID + "】";

                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);
                            listLogStr.Add(sblogstr);
                        }

                        #endregion
                    }

                    #endregion

                    #region 插入客户联系记录

                    if (custHistInfo != null)
                    {
                        custHistInfo.CustID        = retCustID;
                        custHistInfo.ConsultDataID = retDataID;
                        BLL.CustHistoryInfo.Instance.Insert(tran, custHistInfo);
                    }

                    #endregion

                    #region 插入已购车或未购车信息

                    #endregion

                    #region 保存用户操作日志

                    foreach (StringBuilder sbStr in listLogStr)
                    {
                        BLL.Util.InsertUserLog(tran, sbStr.ToString());
                    }
                    #endregion
                }

                if (msg == "")
                {
                    tran.Commit();
                    if (Action == "sub")
                    {
                        #region 调用易湃接口,传回数据

                        string errorMsg    = "";
                        int    retService  = 0;
                        short  isSelectDMS = 0;

                        #region 调用接口

                        BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper OrderHelper = new BitAuto.ISDC.CC2012.WebService.NoDealerOrderHelper();
                        if (Source == "1")                                                    //新车
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetNewCarOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "2")                                                   //置换
                        {
                            isSelectDMS = replaceModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetReplacementOrder(replaceModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }
                        else if (Source == "3")
                        {
                            isSelectDMS = newModel.DMSMemberCode == "" ? (short)2 : (short)1; //1 选择了经销商  2 未选择经销商
                            retService  = OrderHelper.SetTestDriveOrder(newModel, isSelectDMS, NoDealerReason, ref errorMsg);
                        }

                        #endregion

                        #region 插入更新无主订单数据日志表

                        Entities.UpdateOrderData updateDateMode = new UpdateOrderData();
                        updateDateMode.TaskID = TaskID;

                        if (Source == "1" || Source == "3")
                        {
                            updateDateMode.YPOrderID = newModel.YPOrderID;
                        }
                        else if (Source == "2")
                        {
                            updateDateMode.YPOrderID = replaceModel.YPOrderID;
                        }

                        updateDateMode.UpdateType = retService;
                        updateDateMode.IsUpdate   = retService; // 1 成功了,不用处理,-1 需要重新处理
                        if (retService == 1)
                        {
                            updateDateMode.UpdateDateTime = DateTime.Now;
                        }
                        updateDateMode.UpdateErrorMsg = errorMsg;
                        updateDateMode.CreateTime     = DateTime.Now;
                        updateDateMode.CreateUserID   = userID;
                        updateDateMode.APIType        = 1;

                        BLL.UpdateOrderData.Instance.Insert(updateDateMode);

                        #endregion

                        if (retService == -1)
                        {
                            msg = "InterfaceErr|" + errorMsg;
                        }

                        #endregion
                    }
                }
                else
                {
                    tran.Rollback();
                }
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }



            #endregion
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ProjectModel">项目</param>
        /// <param name="userId"></param>
        /// <param name="dt">项目的DataSource数据</param>
        /// <param name="msg"></param>
        public void GenByOtherTaskDataTable(Entities.ProjectInfo ProjectModel, int userId, DataTable dt, out string msg, out string data)
        {
            msg  = "";
            data = "";

            #region panduan

            bool   IsExistCrmCustID = false;
            string ttName           = "";
            string tfName           = "";

            List <Entities.TField> fieldlist = BLL.TField.Instance.GetTFieldListByTTCode(ProjectModel.TTCode);
            Entities.TField        fielditem = fieldlist.Find(delegate(Entities.TField o) { return(o.TFShowCode == "100014"); });
            if (fielditem != null)
            {
                IsExistCrmCustID = true;
                tfName           = fielditem.TFName;

                Entities.TTable tableModel = BLL.TTable.Instance.GetTTableByTTCode(ProjectModel.TTCode);
                if (tableModel != null)
                {
                    ttName = tableModel.TTName;
                }
            }

            #endregion

            #region 根据数据关联生成任务
            List <Entities.OtherTaskInfo> list = new List <Entities.OtherTaskInfo>();
            int       maxcount          = BLL.ProjectTaskInfo.Instance.GetMaxRecID();//从OtherTaskInfo表中查找最大值,不是ProjectTaskInfo表中查找最大值
            DataTable SourceOtherTaskDt = new DataTable();
            SourceOtherTaskDt.Columns.Add("PTID");
            SourceOtherTaskDt.Columns.Add("ProjectID", typeof(int));
            SourceOtherTaskDt.Columns.Add("RelationTableID");
            SourceOtherTaskDt.Columns.Add("RelationID");
            SourceOtherTaskDt.Columns.Add("CreateTime", typeof(DateTime));
            SourceOtherTaskDt.Columns.Add("CreateUserID", typeof(int));
            SourceOtherTaskDt.Columns.Add("LastOptTime", typeof(DateTime));
            SourceOtherTaskDt.Columns.Add("LastOptUserID", typeof(int));
            SourceOtherTaskDt.Columns.Add("TaskStatus", typeof(int));
            SourceOtherTaskDt.Columns.Add("Status", typeof(int));
            SourceOtherTaskDt.Columns.Add("CustID");

            int i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                DataRow newDr = SourceOtherTaskDt.NewRow();

                string PixStr = "";
                if (ProjectModel.Source == 4)
                {
                    PixStr = "OTH";
                }

                newDr["PTID"] = PixStr + (++maxcount).ToString().PadLeft(7, '0');
                //记录最小id和最大id
                if (i == 0)
                {
                    data += "{open:'@open',MinOtherTaskID:'" + newDr["PTID"] + "',";
                }
                if (i + 1 == dt.Rows.Count)
                {
                    data += "MaxOtherTaskID:'" + newDr["PTID"] + "'}";
                }

                newDr["ProjectID"]       = int.Parse(ProjectID);
                newDr["RelationTableID"] = ProjectModel.TTCode;
                newDr["RelationID"]      = dr["RelationID"].ToString();
                newDr["CreateTime"]      = DateTime.Now;
                newDr["CreateUserID"]    = userId;
                newDr["LastOptTime"]     = DateTime.Now;
                newDr["LastOptUserID"]   = userId;
                newDr["TaskStatus"]      = (int)(OtheTaskStatus.Unallocated);
                newDr["Status"]          = 0;
                if (IsExistCrmCustID)
                {
                    newDr["CustID"] = GetCustID(ProjectModel, ttName, tfName, dr["RelationID"].ToString());
                }
                else
                {
                    newDr["CustID"] = "";
                }
                SourceOtherTaskDt.Rows.Add(newDr);
                i++;
            }

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                BLL.Util.BulkCopyToDB(SourceOtherTaskDt, connectionstrings, "OtherTaskInfo", tran, out msg);
                BLL.ProjectLog.Instance.InsertProjectLog(ProjectModel.ProjectID, ProjectLogOper.L6_生成任务, "生成任务" + SourceOtherTaskDt.Rows.Count + "条", tran);

                if (msg == "")
                {
                    #region 修改项目状态
                    ProjectModel.Status = 1;
                    BLL.ProjectInfo.Instance.Update(tran, ProjectModel);
                    #endregion

                    #region 修改关联数据状态
                    BLL.ProjectDataSoure.Instance.UpdateStatusByProjectId(tran, "1", dt, (int)ProjectModel.ProjectID);
                    #endregion

                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        private void GenByDataTable(Entities.ProjectInfo ProjectModel, int userId, DataTable dt, out string msg)
        {
            msg = "";

            #region 根据数据关联生成任务

            List <Entities.ProjectTaskInfo> list       = new List <Entities.ProjectTaskInfo>();
            Entities.ProjectTaskInfo        ptaskModel = null;

            List <Entities.CustLastOperTask> list_OperTask    = new List <Entities.CustLastOperTask>();
            List <Entities.CustLastOperTask> list_OldOperTask = new List <Entities.CustLastOperTask>();

            int maxcount = BLL.ProjectTaskInfo.Instance.GetMax();//从ProjectTaskInfo表中查找最大值

            string PixStr = "";
            if (ProjectModel.Source == 1)
            {
                PixStr = "IMP";
            }
            else if (ProjectModel.Source == 2)
            {
                PixStr = "CRM";
            }
            DateTime dtime = DateTime.Now;

            foreach (DataRow dr in dt.Rows)
            {
                ptaskModel = new Entities.ProjectTaskInfo();

                ptaskModel.PTID = PixStr + (++maxcount).ToString().PadLeft(7, '0');

                ptaskModel.PDSID         = long.Parse(dr["PDSID"].ToString());
                ptaskModel.ProjectID     = int.Parse(ProjectID);
                ptaskModel.CustName      = dr["CustName"].ToString(); //客户名称
                ptaskModel.Source        = int.Parse(dr["Source"].ToString());
                ptaskModel.RelationID    = dr["RelationID"].ToString();
                ptaskModel.CrmCustID     = dr["CustID"].ToString();//CRM客户ID
                ptaskModel.CreateTime    = dtime;
                ptaskModel.CreateUserID  = userId;
                ptaskModel.LastOptTime   = dtime;
                ptaskModel.LastOptUserID = userId;
                ptaskModel.TaskStatus    = (int)(EnumProjectTaskStatus.NoSelEmployee);
                ptaskModel.Status        = 0;
                ptaskModel.CustType      = dr["CustType"].ToString();

                list.Add(ptaskModel);

                if (PixStr == "CRM")
                {
                    Entities.CustLastOperTask operTaskModel = new BitAuto.ISDC.CC2012.Entities.CustLastOperTask();

                    if (ptaskModel.CrmCustID != "")
                    {
                        Entities.CustLastOperTask oldModel = BLL.CustLastOperTask.Instance.GetCustLastOperTask(ptaskModel.CrmCustID);
                        if (oldModel == null)
                        {
                            operTaskModel.CustID         = ptaskModel.CrmCustID;
                            operTaskModel.TaskID         = ptaskModel.PTID;
                            operTaskModel.TaskType       = 1;
                            operTaskModel.LastOperUserID = operTaskModel.CreateUserID = BLL.Util.GetLoginUserID();
                            operTaskModel.LastOperTime   = operTaskModel.CreateTime = dtime;
                            list_OperTask.Add(operTaskModel);
                            list_OldOperTask.Add(null);
                        }
                        else
                        {
                            operTaskModel.CustID         = ptaskModel.CrmCustID;
                            operTaskModel.TaskID         = ptaskModel.PTID;
                            operTaskModel.LastOperUserID = BLL.Util.GetLoginUserID();
                            operTaskModel.LastOperTime   = dtime;
                            list_OperTask.Add(operTaskModel);
                            list_OldOperTask.Add(oldModel);
                        }
                    }
                }
            }

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                //add by qizq 2013-3-11 4S和非4S电话营销
                if (ProjectModel.Source != 3) //Modify By Chybin At 2014-3-31
                {
                    #region 生成任务
                    foreach (Entities.ProjectTaskInfo item in list)
                    {
                        BLL.ProjectTaskInfo.Instance.Add(tran, item);
                    }
                    BLL.ProjectLog.Instance.InsertProjectLog(ProjectModel.ProjectID, ProjectLogOper.L6_生成任务, "生成任务" + list.Count + "条", tran);
                    #endregion
                }

                #region 修改项目状态
                ProjectModel.Status = 1;
                BLL.ProjectInfo.Instance.Update(tran, ProjectModel);
                #endregion

                #region 修改关联数据状态
                BLL.ProjectDataSoure.Instance.UpdateStatusByProjectId(tran, "1", (int)ProjectModel.ProjectID);
                #endregion

                tran.Commit();
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }



            #endregion
        }
        //删除
        public void deleteKnowledgeLib(out string msg)
        {
            msg = string.Empty;
            string[] KLIDs = RequestKLID.Split(',');
            if (KLIDs.Length == 0)
            {
                msg += "{'msg':'没有对应的ID值,操作失败'}";
                return;
            }
            string klqids = string.Empty;   //记录试题库中的主键信息;已 1,2,3|4,5,6|7,8,9 形式隔开

            for (int j = 0; j < KLIDs.Length; j++)
            {
                //根据KLID找到试题库中的信息
                QueryKLQuestion query = new QueryKLQuestion();
                query.KLID = long.Parse(KLIDs[j]);
                int       count;
                DataTable dt = BLL.KLQuestion.Instance.GetKLQuestion(query, "", 1, 10000, out count);
                for (int m = 0; m < dt.Rows.Count; m++)
                {
                    klqids += dt.Rows[m]["KLQID"].ToString() + ",";
                }
                klqids = klqids.TrimEnd(',') + "|";
            }
            klqids = klqids.TrimEnd('|');

            #region  除 事务操作

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");
            try
            {
                //1 将知识库信息状态修改为 4已删除
                operateKnowledgeLib(4, tran, out msg);
                for (int i = 0; i < KLIDs.Length; i++)
                {
                    //2 将KLQuestion知识库试题记录修改为 -1已删除
                    string[] klqid1 = klqids.Split('|');
                    for (int n = 0; n < klqid1.Length; n++)
                    {
                        string[] klqid2 = klqid1[n].Split(',');
                        for (int p = 0; p < klqid2.Length; p++)
                        {
                            deleteKLQuestionByKLID(tran, klqid2[p]);
                        }
                    }
                    //3 将KLUploadFile 知识库上传文件信息表记录 修改为 -1已删除
                    deleteKLUploadFileByKLID(tran, KLIDs[i]);
                    //4 将KLFAQ知识库FAQ表记录修改为 -1已删除
                    deleteKLFAQByKLID(tran, KLIDs[i]);
                    //5 插入一条记录到KLOptionLog知识库操作日志表
                    InsertKLOptionLog(tran, (int)Entities.EnumOptStatus.Delete, KLIDs[i]);
                }

                //事务提交
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = "{'msg':'" + ex.Message.ToString() + "'}";
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }
Beispiel #21
0
        private void Submit(out string msg, int userID, out string returnTTCode)
        {
            msg          = "";
            returnTTCode = "";

            string       datainfoStr    = DataStr;
            TemplateInfo tempInfoData   = null;
            int          templateStatus = -1;//模板状态

            Entities.TPage         tpageModel    = new Entities.TPage();
            Entities.TTable        ttable        = new Entities.TTable();
            List <Entities.TField> editfieldList = new List <Entities.TField>();
            List <Entities.TField> addfieldList  = new List <Entities.TField>();

            Entities.TField fieldModel = new Entities.TField();

            List <Entities.TField> delFields = new List <Entities.TField>();

            tempInfoData = (TemplateInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(datainfoStr, typeof(TemplateInfo));

            #region 验证数据

            CheckMsg(tempInfoData, out msg);

            if (msg != "")
            {
                return;
            }
            #endregion

            #region 准备数据

            if (tempInfoData.ttcode != "")
            {
                //编辑

                #region 模板信息

                tpageModel = BLL.TPage.Instance.GetTPageByTTCode(tempInfoData.ttcode);
                if (tpageModel != null)
                {
                    //状态
                    templateStatus = BLL.TPage.Instance.getStatus(tpageModel.RecID.ToString(), tpageModel.Status.ToString());

                    if (templateStatus != 0)
                    {
                        msg += "模板当前状态下不允许编辑";
                        return;
                    }

                    tpageModel.TPName             = tempInfoData.templateName;
                    tpageModel.BGID               = int.Parse(tempInfoData.BGID);
                    tpageModel.SCID               = int.Parse(tempInfoData.CID);
                    tpageModel.TPContent          = tempInfoData.templateDesc;
                    tpageModel.IsShowBtn          = int.Parse(tempInfoData.IsShowBtn);
                    tpageModel.IsShowWorkOrderBtn = int.Parse(tempInfoData.IsShowWorkOrderBtn);
                    tpageModel.IsShowSendMsgBtn   = int.Parse(tempInfoData.IsShowSendMsgBtn);
                    tpageModel.IsShowQiCheTong    = int.Parse(tempInfoData.IsShowQiCheTong);
                    tpageModel.IsShowSubmitOrder  = int.Parse(tempInfoData.IsShowSubmitOrder);
                }
                else
                {
                    msg += "没有找到相关模板信息";
                    return;
                }

                #endregion

                #region 自定义数据表

                ttable = BLL.TTable.Instance.GetTTableByTTCode(tempInfoData.ttcode);
                if (ttable != null)
                {
                    ttable.TTDesName = tempInfoData.templateName;
                }
                else
                {
                    msg += "没有找到相关的自定义表信息";
                    return;
                }

                #endregion

                #region 编辑字段
                editfieldList = BLL.TField.Instance.GetTFieldListByTTCode(tempInfoData.ttcode);
                List <FieldInfoData> updateFieldInfo = new List <FieldInfoData>();
                #region 新增的
                for (int i = tempInfoData.fieldListInfo.Length - 1; i >= 0; i--)
                {
                    if (tempInfoData.fieldListInfo[i].RecID == "")
                    {
                        //新增
                        fieldModel = GetOneFieldMode(userID, tempInfoData.fieldListInfo[i], tpageModel.TTCode, "");
                        addfieldList.Add(fieldModel);
                    }
                    else
                    {
                        //编辑的
                        updateFieldInfo.Add(tempInfoData.fieldListInfo[i]);
                    }
                }
                #endregion

                int existflog = 0;
                for (int i = editfieldList.Count - 1; i >= 0; i--)
                {
                    existflog = 0;
                    if (tempInfoData.fieldListInfo != null)
                    {
                        foreach (FieldInfoData field in updateFieldInfo)
                        {
                            if (field.RecID == editfieldList[i].RecID.ToString())
                            {
                                //编辑
                                editfieldList[i].TFDesName      = field.TFDesName;
                                editfieldList[i].TFDes          = field.TFDes;
                                editfieldList[i].TFInportIsNull = int.Parse(field.TFInportIsNull);
                                editfieldList[i].TFIsNull       = int.Parse(field.TFIsNull);
                                editfieldList[i].TFSortIndex    = int.Parse(field.TFSortIndex);
                                editfieldList[i].TFIsExportShow = int.Parse(field.TFIsExportShow);
                                editfieldList[i].TFIsListShow   = int.Parse(field.TFIsListShow);
                                editfieldList[i].TFValue        = field.TFValue;
                                editfieldList[i].TFCssName      = field.TFCssName;
                                existflog = 1;
                            }
                        }

                        // //在页面传来的对象中没有,是删除
                        if (existflog == 0)
                        {
                            //删除的
                            delFields.Add(editfieldList[i]);
                            editfieldList.RemoveAt(i);
                        }
                    }
                }
                #endregion
            }
            else
            {
                //新增
                #region 自定义数据表

                int maxID = BLL.TTable.Instance.GetMaxID();

                ttable.TTCode       = "t" + maxID;
                ttable.TTDesName    = tempInfoData.templateName;
                ttable.TTName       = "Tempt" + maxID;
                ttable.Status       = 0;
                ttable.CreateTime   = DateTime.Now;
                ttable.CreateUserID = userID;

                #endregion

                #region 模板表
                tpageModel.TPName             = tempInfoData.templateName;
                tpageModel.BGID               = int.Parse(tempInfoData.BGID);
                tpageModel.SCID               = int.Parse(tempInfoData.CID);
                tpageModel.TPRef              = "";
                tpageModel.TTCode             = ttable.TTCode;
                tpageModel.TPContent          = tempInfoData.templateDesc;
                tpageModel.GenTempletPath     = "";
                tpageModel.Status             = 0;
                tpageModel.Remark             = "";
                tpageModel.CreateTime         = DateTime.Now;
                tpageModel.CreateUserID       = userID;
                tpageModel.TTName             = ttable.TTName;
                tpageModel.IsShowBtn          = int.Parse(tempInfoData.IsShowBtn);
                tpageModel.IsShowWorkOrderBtn = int.Parse(tempInfoData.IsShowWorkOrderBtn);
                tpageModel.IsShowSendMsgBtn   = int.Parse(tempInfoData.IsShowSendMsgBtn);
                tpageModel.IsShowQiCheTong    = int.Parse(tempInfoData.IsShowQiCheTong);
                tpageModel.IsShowSubmitOrder  = int.Parse(tempInfoData.IsShowSubmitOrder);
                tpageModel.IsUsed             = -1;
                #endregion

                #region 字段

                if (tempInfoData.fieldListInfo != null)
                {
                    foreach (FieldInfoData item in tempInfoData.fieldListInfo)
                    {
                        string ttCode = ttable.TTCode;

                        fieldModel = GetOneFieldMode(userID, item, ttCode, "");

                        addfieldList.Add(fieldModel);
                    }
                }

                #endregion
            }

            #endregion

            #region 提交事务

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                if (tempInfoData.ttcode == "")
                {
                    //新增

                    BLL.TPage.Instance.Insert(tran, tpageModel);

                    BLL.TTable.Instance.Insert(tran, ttable);

                    //新增的字段
                    foreach (Entities.TField item in addfieldList)
                    {
                        BLL.TField.Instance.Insert(tran, item);
                    }

                    returnTTCode = tpageModel.TTCode;
                }
                else
                {
                    //编辑

                    BLL.TPage.Instance.Update(tran, tpageModel);

                    BLL.TTable.Instance.Update(tran, ttable);

                    //编辑的字段
                    foreach (Entities.TField item in editfieldList)
                    {
                        BLL.TField.Instance.Update(tran, item);
                    }

                    //新增的字段
                    foreach (Entities.TField item in addfieldList)
                    {
                        BLL.TField.Instance.Insert(tran, item);

                        #region 如果已经生成模板,添加物理表的字段(修改为:模板生成了,还可以修改,⊙﹏⊙b汗)

                        if (templateStatus == 1)
                        {
                            try
                            {
                                List <string> addNames = GetRealFieldName(item);

                                foreach (string name in addNames)
                                {
                                    BLL.TField.Instance.AddColumn(ttable.TTName, name, item.TTypeID.ToString());
                                }
                            }
                            catch (Exception ex)
                            {
                                msg += "添加数据表字段失败!<br>";
                            }
                        }

                        #endregion
                    }

                    //删除的字段

                    foreach (Entities.TField item in delFields)
                    {
                        BLL.TField.Instance.Delete(item.RecID);

                        #region 如果已经生成模板,删除物理表的字段

                        if (templateStatus == 1)
                        {
                            try
                            {
                                List <string> delNames = GetRealFieldName(item);

                                foreach (string name in delNames)
                                {
                                    BLL.TField.Instance.DelColumn(ttable.TTName, name);
                                }
                            }
                            catch (Exception ex)
                            {
                                msg += "删除数据表字段失败!<br>";
                            }
                        }

                        #endregion
                    }

                    returnTTCode = tpageModel.TTCode;
                }


                tran.Commit();
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }
        public void ProcessRequest(HttpContext context)
        {
            BitAuto.YanFa.SysRightManager.Common.UserInfo.Check();
            context.Response.ContentType = "text/plain";
            currentContext = context;
            int  userID  = BLL.Util.GetLoginUserID();
            bool IsRight = BLL.Util.CheckRight(userID, "SYS024BUT5104");

            if (IsRight && currentContext.Request.Form["isVal"] == "yes")
            {
                if ((RequestUsername != null && RequestUsername.Length > 0))
                {
                    int    ret = 0;
                    string url = string.Empty;


                    //工号
                    //string agentNum = Page.Request.Form["AgentNum"] + "";
                    //if (string.IsNullOrEmpty(agentNum) == false
                    //    && BLL.CC_Employee_Agent.Instance.IsExist(agentNum, Convert.ToInt32(Session["userid"])) == false)//有工号
                    //{
                    //    ret = -9;//工号错误
                    //}
                    //else
                    //{


                    //域账号
                    string username = RequestUsername.ToLower();
                    //string adminUserName = "******";//Add=2013-03-21 Masj 模拟登陆魏淑珍账号验证登陆权限 //this.RequestAdminUsername.ToLower();
                    string adminUserName = BLL.Util.GetLoginUserName();//Add=2014-07-07 Masj 模拟登陆账号为当前登录者的账号

                    if (username.StartsWith("tech\\"))
                    {
                        username = username.Substring(5, username.Length - 5);
                    }
                    //string password = Request.Form["pwd"];
                    string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                    IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                             organizationService);

                    LoginResult loginResult = service.Login(adminUserName, RequestPWD);
                    if (loginResult == LoginResult.Success)
                    {
                        ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username);
                        if (ret > 0)
                        {
                            BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                            string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                            if (!string.IsNullOrEmpty(RequestGoURL))
                            {
                                gourl = RequestGoURL;
                            }
                            else
                            {
                                gourl = ConfigurationUtil.GetAppSettingValue("ExitAddress");
                                //DataTable dtParent = UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                                //if (dtParent != null)
                                //{
                                //    DataTable dtChild = UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                                //    if (dtChild.Rows.Count > 0)
                                //    {
                                //        gourl = dtChild.Rows[0]["url"].ToString();
                                //    }
                                //}
                            }
                            ret = 1;//登陆成功
                            string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                            BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                            url = gourl;
                        }
                        else
                        {
                        }
                    }
                    else if (loginResult == LoginResult.Inactive)
                    {
                        ret = -6;//帐户被禁用
                    }
                    else if (loginResult == LoginResult.UserNotExist)
                    {
                        ret = -7;//用户不存在
                    }
                    else if (loginResult == LoginResult.WrongPassword)
                    {
                        ret = -8;//密码错误
                    }


                    //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                    context.Response.Write(ret.ToString() + "," + url);
                    context.Response.End();
                    return;
                }
            }
            context.Response.Write("-1,");
            context.Response.End();
        }
Beispiel #23
0
        private void ShowRoles()
        {
            DataTable dt = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetRoleInfoByUserIDAndSysID(int.Parse(UserID), ConfigurationUtil.GetAppSettingValue("ThisSysID"));

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    UserRolesIDs += dr["RoleID"].ToString() + ",";
                }

                if (UserRolesIDs != "")
                {
                    UserRolesIDs = UserRolesIDs.Substring(0, UserRolesIDs.Length - 1);
                }
            }
        }
        private void SaveInfo(out string errMsg)
        {
            errMsg = "";

            #region 保存对权限的设置

            BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.InsertUserRole(int.Parse(UserID), ConfigurationUtil.GetAppSettingValue("ThisSysID"), UserRolesID);

            #endregion

            #region 修改所在分组、工号

            SaveEmpleeInfo();

            #endregion

            #region 修改管辖分组

            SaveManagerGroup();

            #endregion
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!Pwd.ToLower().Equals("3219jdhliweruy@hfkjhi@oghg"))
         {
             BitAuto.Utils.ScriptHelper.ShowAlertScript("您无此页面权限!");
             Response.End();
         }
         else
         {
             DataTable db = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetRoleInfoBySysID(ConfigurationUtil.GetAppSettingValue("ThisSysID"));
             Rpt_Role.DataSource = db;
             Rpt_Role.DataBind();
         }
     }
 }
        /// 新增或者修改分组
        /// <summary>
        /// 新增或者修改分组
        /// </summary>
        /// <param name="msg"></param>
        private void DisposeBusinessGroup(out string msg)
        {
            msg = string.Empty;
            try
            {
                Entities.BusinessGroup model = BLL.Util.BindQuery <Entities.BusinessGroup>(HttpContext.Current);
                if (model.BGID > 0)
                {
                    //修改逻辑
                    Entities.BusinessGroup info = BLL.BusinessGroup.Instance.GetBusinessGroupInfoByBGID(model.BGID);
                    if (info != null)
                    {
                        info.Name         = model.Name;
                        info.RegionID     = model.RegionID;
                        info.BusinessType = model.BusinessType;
                        //业务包含cc,才有外显号码
                        if ((CommonFunction.ObjectToInteger(model.BusinessType) & (int)BusinessTypeEnum.CC) == (int)BusinessTypeEnum.CC)
                        {
                            info.CDID = model.CDID;
                        }
                        else
                        {
                            info.CDID = -2;
                        }
                        //修改组数据
                        BLL.BusinessGroup.Instance.Update(info);
                        //业务包含im时
                        if ((CommonFunction.ObjectToInteger(model.BusinessType) & (int)BusinessTypeEnum.IM) == (int)BusinessTypeEnum.IM)
                        {
                            //清空业务线数据
                            BLL.BusinessGroupLineMapping.Instance.Delete(model.BGID);
                            //插入业务线数据
                            InsertBusinessGroupLineMapping(model.BGID, model.LineIDs);
                        }
                        else
                        {
                            //清空业务线数据
                            BLL.BusinessGroupLineMapping.Instance.Delete(model.BGID);
                        }

                        msg = "{result:'yes',BGID:'" + model.BGID + "',AreaID:'" + AreaID + "',msg:'保存成功'}";
                    }
                    else
                    {
                        msg = "{result:'no',BGID:'" + model.BGID + "',AreaID:'" + AreaID + "',msg:'没有找到对应分组信息'}";
                    }
                }
                else
                {
                    //新增逻辑
                    model.CreateTime = DateTime.Now;
                    model.Status     = 0;
                    //业务包含cc,才有外显号码
                    if ((CommonFunction.ObjectToInteger(model.BusinessType) & (int)BusinessTypeEnum.CC) != (int)BusinessTypeEnum.CC)
                    {
                        model.CDID = -2;
                    }
                    //插入组数据
                    int id = BLL.BusinessGroup.Instance.Insert(model);
                    //业务包含im时
                    if ((CommonFunction.ObjectToInteger(model.BusinessType) & (int)BusinessTypeEnum.IM) == (int)BusinessTypeEnum.IM)
                    {
                        //插入业务线数据
                        InsertBusinessGroupLineMapping(id, model.LineIDs);
                    }

                    //创建分类
                    Entities.SurveyCategory categoryModel = new Entities.SurveyCategory();
                    categoryModel.BGID         = id;
                    categoryModel.Status       = -3;
                    categoryModel.CreateTime   = DateTime.Now;
                    categoryModel.CreateUserID = BLL.Util.GetLoginUserID();
                    categoryModel.Name         = "工单分类";
                    categoryModel.TypeId       = 2;
                    int scId = BLL.SurveyCategory.Instance.Insert(categoryModel);

                    //创建业务线url地址
                    string webBaseUrl = ConfigurationUtil.GetAppSettingValue("ExitAddress");
                    webBaseUrl = webBaseUrl + "/WorkOrder/WorkOrderView.aspx?OrderID={0}";
                    BLL.CallRecord_ORIG_Business.Instance.AddBusinessUrl(id, scId, webBaseUrl);

                    msg = "{result:'yes',BGID:'" + id + "',AreaID:'" + AreaID + "',msg:'保存成功'}";
                }
            }
            catch (Exception ex)
            {
                msg = "{result:'no',BGID:'',AreaID:'',msg:'" + ex.Message + "'}";
            }
        }
Beispiel #27
0
        private void VerifyData()
        {
            string sysId  = ConfigurationUtil.GetAppSettingValue("ThisSysID");
            int    userId = BLL.Util.GetLoginUserID();

            FirstTrialButton = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.CheckRight("SYS024BUT600102", sysId, userId);
            RecheckButton    = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.CheckRight("SYS024BUT600103", sysId, userId);
            AppealButton     = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.CheckRight("SYS024BUT600106", sysId, userId);

            int rid = 0;

            if (int.TryParse(RequestQS_RID, out rid))
            {
                Entities.QS_Result info = BLL.QS_Result.Instance.GetQS_Result(rid);
                if (info != null)
                {
                    //由于易湃外呼业务签入cc系统,易湃不入库CallRecordInfo表,所以此处改成从CallRecord_ORIG_Business取录音创建坐席 modify by qizq 2014-4-17
                    Entities.CallRecord_ORIG_Business callRecordInfo = BLL.CallRecord_ORIG_Business.Instance.GetByCallID(Convert.ToInt64(info.CallID), tableEndName);
                    //Entities.CallRecordInfo callRecordInfo = BLL.CallRecordInfo.Instance.GetCallRecordInfoByCallID(info.CallID);
                    if (callRecordInfo != null)
                    {
                        //判断单据状态,如果不是待复审,不能复审
                        Entities.QS_RulesTable QS_RulesTableModel = BLL.QS_RulesTable.Instance.GetQS_RulesTable(info.QS_RTID);
                        if (QS_RulesTableModel != null)
                        {
                            TableName = QS_RulesTableModel.Name;
                            if (QS_RulesTableModel.ScoreType == 2)
                            {
                                TableName += "(致命项数" + QS_RulesTableModel.DeadItemNum + ",非致命项数" + QS_RulesTableModel.NoDeadItemNum + ")";
                            }
                        }

                        //如果具有申诉权限,并且当前人不是此录音的创建人员,关闭此页面
                        if (AppealButton && callRecordInfo.CreateUserID != BLL.Util.GetLoginUserID() & !RecheckButton & !AppealButton)
                        {
                            Response.Write(@"<script language='javascript'>alert('您没有权限查看此评分!');try {
                  window.external.MethodScript('/browsercontrol/closepage');
            } catch (e) {
                window.opener = null; window.open('', '_self'); window.close();
            };</script>");
                        }
                        //如果不是本人录音,申诉按钮不显示
                        if (AppealButton && callRecordInfo.CreateUserID != BLL.Util.GetLoginUserID())
                        {
                            AppealButton = false;
                        }
                        this.ucCallRecordView.QS_RID       = info.QS_RID;
                        this.ucCallRecordView.CallID       = info.CallID;
                        this.ucCallRecordView.tableEndName = tableEndName;
                    }
                    Status = info.Status.ToString();
                    switch (Status)
                    {
                    case "20003":
                        Title = "录音质检成绩初审";
                        this.UCScoreTableView.QS_RID  = info.QS_RID;
                        this.UCScoreTableView.QS_RTID = info.QS_RTID;
                        break;

                    case "20004":
                        Title = "录音质检成绩复审";
                        this.ucTableDispose.CallID  = info.CallID;
                        this.ucTableDispose.QS_RID  = info.QS_RID;
                        this.ucTableDispose.QS_RTID = info.QS_RTID;
                        break;

                    default:
                        Title = "录音质检成绩查看";
                        this.UCScoreTableView.QS_RID  = info.QS_RID;
                        this.UCScoreTableView.QS_RTID = info.QS_RTID;
                        break;
                    }
                }
                else
                {
                    Response.Write(@"<script language='javascript'>alert('不存在此评分!');try {
                  window.external.MethodScript('/browsercontrol/closepage');
            } catch (e) {
                window.opener = null; window.open('', '_self',''); window.close();
            };</script>");
                }
            }
            else
            {
                Response.Write(@"<script language='javascript'>alert('参数有误!');try {
                  window.external.MethodScript('/browsercontrol/closepage');
            } catch (e) {
                window.opener = null; window.open('', '_self',''); window.close();
            };</script>");
            }
        }
        /// 挂断通用事件
        /// <summary>
        /// 挂断通用事件
        /// </summary>
        /// <param name="releasetype"></param>
        private void OnHangup(ReleaseType releasetype)
        {
            Loger.Log4Net.Info("[事件][OnHangup] 挂断");
            //3种情况=呼入,呼出,未知
            Calltype ctype = HollyContactHelper.Instance.GetCallDir();

            //话后处理
            if (ctype == Calltype.C2_呼出)
            {
                //合力bug:外呼假失败
                HollyBUGForCallOut();
                //呼出没有话后
                Action <object> callback = new Action <object>(x =>
                {
                    //结束话后
                    HollyContactHelper.Instance.AfterCallEnd();
                    //呼出时计算话后信息
                    Loger.Log4Net.Info("[==BusinessProcess=][UpdateCallRecordAfterTime] 呼出时退出话后更新话后信息");
                    BusinessProcess.Instance.UpdateCallRecordAfterTime();
                });
                ToAfterCallCallBack(callback);
            }
            else
            {
                //呼入+自动外呼 存在话后时间
                //话后有时间限制
                AfterTime = CommonFunction.ObjectToInteger(ConfigurationUtil.GetAppSettingValue("AfterTime"), 60);
                SetlblAgentStatusName("话后 " + AfterTime);
                timer_after.Enabled = true;
            }

            if (BusinessProcess.CallRecordORIG != null)
            {
                //初始化话务数据
                DateTime date = Common.GetCurrentTime();
                //设置挂断时间
                BusinessProcess.Instance.SetReleaseTime(date, releasetype);
                //数据入库
                CallRecordHelper.Instance.InsertCallRecordNew(false);

                if (ctype != Calltype.C2_呼出)
                {
                    //呼入+自动外呼时,计算话后信息
                    //注册退出话后的事件
                    Action <object> callback = new Action <object>(x =>
                    {
                        Loger.Log4Net.Info("[==BusinessProcess=][UpdateCallRecordAfterTime] 呼入时退出话后更新话后信息");
                        BusinessProcess.Instance.UpdateCallRecordAfterTime();
                    });
                    //退出话后时触发
                    ExitAfterCallCallBack(callback);
                }

                //发送消息到客户端
                if (BusinessProcess.OutBoundType != OutBoundTypeEnum.OT2_客户端呼出)
                {
                    UserEventData ud = null;
                    //呼入(普通呼入,转接,拦截)
                    if (ctype == Calltype.C1_呼入 && HollyContactHelper.Instance.IsAutoCall == false)
                    {
                        ud = BusinessProcess.Instance.InitUserEventData(UserEvent.Released, Calltype.C1_呼入, date);
                    }
                    //呼出(呼出,自动外呼,未知)
                    else
                    {
                        ud = BusinessProcess.Instance.InitUserEventData(UserEvent.Released, Calltype.C2_呼出, date);
                    }
                    SendToWeb(ud.ToString());
                }
                //挂断是,数据还原初始值
                BusinessProcess.OutBoundType = OutBoundTypeEnum.OT0_未知;
            }
            else
            {
                Loger.Log4Net.Info("[事件][OnHangup] 异常:BusinessProcess.CallRecordORIG 为空");
            }
        }
Beispiel #29
0
 public string GetIMUrl()
 {
     return(ConfigurationUtil.GetAppSettingValue("PersonalIMURL") + "/ConversationHistoryForCCDetail.aspx");
 }
Beispiel #30
0
        private void Submit(out string msg, int userID, out string returnRTID)
        {
            msg        = "";
            returnRTID = "";

            #region 定义变量

            string         datainfoStr = DataStr;
            ScoreTableInfo tempInfoData;

            Entities.QS_RulesTable      QsTable;
            Entities.QS_Category        QsCategory;
            Entities.QS_Item            QsItem;
            Entities.QS_Standard        QsStandard;
            Entities.QS_Marking         QsMarking;
            Entities.QS_DeadOrAppraisal Qsdead;


            List <Entities.QS_Category>        QsCategoryList = new List <Entities.QS_Category>();
            List <Entities.QS_Item>            QsItemList     = new List <Entities.QS_Item>();
            List <Entities.QS_Standard>        QsStandardList = new List <Entities.QS_Standard>();
            List <Entities.QS_Marking>         QsMarkingList  = new List <Entities.QS_Marking>();
            List <Entities.QS_DeadOrAppraisal> QsDeadList     = new List <Entities.QS_DeadOrAppraisal>();

            #endregion

            tempInfoData = (ScoreTableInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(datainfoStr, typeof(ScoreTableInfo));

            #region 验证数据
            //判断是否是提交,提交才验证,add by qizq
            if (ActionType == "Submit")
            {
                CheckMsg(tempInfoData, out msg);

                if (msg != "")
                {
                    return;
                }
            }
            //
            #endregion

            #region 准备数据

            #region 评分表

            QsTable             = new Entities.QS_RulesTable();
            QsTable.QS_RTID     = int.Parse(tempInfoData.RTID);
            QsTable.Name        = tempInfoData.Name;
            QsTable.ScoreType   = int.Parse(tempInfoData.ScoreType);
            QsTable.Description = tempInfoData.Description;

            QsTable.DeadItemNum      = int.Parse(tempInfoData.DeadItemNum);
            QsTable.NoDeadItemNum    = int.Parse(tempInfoData.NoDeadItemNum);
            QsTable.HaveQAppraisal   = int.Parse(tempInfoData.Appraisal);
            QsTable.LastModifyTime   = DateTime.Now;
            QsTable.LastModifyUserID = userID.ToString();
            QsTable.RegionID         = tempInfoData.RegionID;

            if (QsTable.QS_RTID < 0)
            {
                if (BLL.QS_RulesTable.Instance.IsRuleTableNameExist(QsTable.Name, QsTable.ScoreType))
                {
                    msg = "评分表名称[" + QsTable.Name + "]已经存在,不能重复添加!";
                    return;
                }
            }

            //add by qizq 添加日志2013-5-8
            StringBuilder sbStr = new StringBuilder();

            if (ActionType == "Submit")
            {
                sbStr.Append("提交评分表 " + QsTable.Name);
                QsTable.Status = (int)Entities.QSRulesTableStatus.Audit;
            }
            else
            {
                sbStr.Append("保存评分表 " + QsTable.Name);
                QsTable.Status = (int)Entities.QSRulesTableStatus.Unfinished;
            }

            #endregion

            #region 评分分类

            if (tempInfoData.Catage != null)
            {
                foreach (Catage catageInfo in tempInfoData.Catage)
                {
                    QsCategory                  = new Entities.QS_Category();
                    QsCategory.QS_CID           = int.Parse(catageInfo.CID);
                    QsCategory.QS_RTID          = int.Parse(tempInfoData.RTID);//评分表的值
                    QsCategory.Name             = catageInfo.Name;
                    QsCategory.Score            = int.Parse(catageInfo.Score);
                    QsCategory.Status           = int.Parse(catageInfo.Status);
                    QsCategory.ScoreType        = int.Parse(tempInfoData.ScoreType); //评分表的值
                    QsCategory.LastModifyTime   = DateTime.Now;
                    QsCategory.LastModifyUserID = userID;

                    QsCategoryList.Add(QsCategory);

                    #region 质检项目

                    if (catageInfo.Item != null)
                    {
                        foreach (Item itemInfo in catageInfo.Item)
                        {
                            QsItem                  = new Entities.QS_Item();
                            QsItem.QS_IID           = int.Parse(itemInfo.IID);
                            QsItem.QS_CID           = int.Parse(catageInfo.CID);
                            QsItem.QS_RTID          = int.Parse(tempInfoData.RTID);
                            QsItem.ItemName         = itemInfo.ItemName;
                            QsItem.ScoreType        = int.Parse(tempInfoData.ScoreType);
                            QsItem.Score            = decimal.Parse(itemInfo.Score);
                            QsItem.Status           = int.Parse(itemInfo.Status);
                            QsItem.LastModifyTime   = DateTime.Now;
                            QsItem.LastModifyUserID = userID;

                            QsItemList.Add(QsItem);

                            #region 质检标准

                            if (itemInfo.Standard != null)
                            {
                                foreach (Standard standardInfo in itemInfo.Standard)
                                {
                                    if (standardInfo.Score.Trim() != "" && standardInfo.SName.Trim() != "") //&& standardInfo.Status.Trim() == "0"
                                    {
                                        QsStandard                     = new Entities.QS_Standard();
                                        QsStandard.QS_SID              = int.Parse(standardInfo.SID);
                                        QsStandard.QS_IID              = int.Parse(itemInfo.IID);
                                        QsStandard.QS_CID              = int.Parse(catageInfo.CID);
                                        QsStandard.QS_RTID             = int.Parse(tempInfoData.RTID);
                                        QsStandard.ScoringStandardName = standardInfo.SName;
                                        QsStandard.ScoreType           = int.Parse(tempInfoData.ScoreType);
                                        QsStandard.Score               = decimal.Parse(standardInfo.Score);
                                        QsStandard.IsIsDead            = string.IsNullOrEmpty(standardInfo.IsIsDead) ? -2 : int.Parse(standardInfo.IsIsDead);
                                        QsStandard.Status              = int.Parse(standardInfo.Status);
                                        QsStandard.LastModifyTime      = DateTime.Now;
                                        QsStandard.LastModifyUserID    = userID;

                                        QsStandard.QS_SExplanation = standardInfo.SExplanation;
                                        QsStandard.QS_SkillLevel   = standardInfo.SkillLevel == null ? Constant.INT_INVALID_VALUE: int.Parse(standardInfo.SkillLevel);

                                        QsStandardList.Add(QsStandard);
                                    }

                                    #region 扣分项

                                    if (standardInfo.Marking != null && tempInfoData.ScoreType.Trim() != "3")
                                    {
                                        foreach (Marking markInfo in standardInfo.Marking)
                                        {
                                            QsMarking = new Entities.QS_Marking();

                                            QsMarking.QS_MID          = int.Parse(markInfo.MID);
                                            QsMarking.QS_RTID         = int.Parse(tempInfoData.RTID);
                                            QsMarking.QS_CID          = int.Parse(catageInfo.CID);
                                            QsMarking.QS_IID          = int.Parse(itemInfo.IID);
                                            QsMarking.QS_SID          = int.Parse(standardInfo.SID);
                                            QsMarking.ScoreType       = int.Parse(tempInfoData.ScoreType);
                                            QsMarking.MarkingItemName = markInfo.MName;
                                            QsMarking.Score           = int.Parse(markInfo.Score);
                                            QsMarking.Status          = int.Parse(markInfo.Status);

                                            QsMarkingList.Add(QsMarking);
                                        }
                                    }

                                    #endregion
                                }
                            }


                            #endregion
                        }
                    }

                    #endregion
                }
            }

            #endregion

            #region 致命项

            if (tempInfoData.Dead != null)
            {
                foreach (Dead deadInfo in tempInfoData.Dead)
                {
                    Qsdead                  = new Entities.QS_DeadOrAppraisal();
                    Qsdead.QS_DAID          = int.Parse(deadInfo.DID);
                    Qsdead.QS_RTID          = int.Parse(tempInfoData.RTID);
                    Qsdead.DeadItemName     = deadInfo.DName;
                    Qsdead.Status           = int.Parse(deadInfo.Status);
                    Qsdead.LastModifyTime   = DateTime.Now;
                    Qsdead.LastModifyUserID = userID;

                    QsDeadList.Add(Qsdead);
                }
            }

            #endregion

            #endregion

            #region 提交到数据库

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction(IsolationLevel.ReadUncommitted);
            //  SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                #region 保存评分表

                if (QsTable.QS_RTID < 0)
                {
                    //新增

                    QsTable.CreateTime   = DateTime.Now;
                    QsTable.CreateUserID = userID;
                    int retID = BLL.QS_RulesTable.Instance.Insert(tran, QsTable);
                    returnRTID = retID.ToString();

                    #region 修改各个表的评分表ID

                    foreach (Entities.QS_Category cItem in QsCategoryList)
                    {
                        if (cItem.QS_RTID == QsTable.QS_RTID)
                        {
                            cItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Item iItem in QsItemList)
                    {
                        if (iItem.QS_RTID == QsTable.QS_RTID)
                        {
                            iItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Standard sItem in QsStandardList)
                    {
                        if (sItem.QS_RTID == QsTable.QS_RTID)
                        {
                            sItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Marking mItem in QsMarkingList)
                    {
                        if (mItem.QS_RTID == QsTable.QS_RTID)
                        {
                            mItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_DeadOrAppraisal dItem in QsDeadList)
                    {
                        if (dItem.QS_RTID == QsTable.QS_RTID)
                        {
                            dItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    #endregion
                }
                else
                {
                    //编辑
                    BLL.QS_RulesTable.Instance.Update(tran, QsTable);
                    returnRTID = QsTable.QS_RTID.ToString();
                }

                #endregion

                #region 保存分类

                foreach (Entities.QS_Category cItem in QsCategoryList)
                {
                    if (cItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Category.Instance.Delete(tran, cItem.QS_CID);
                        continue;
                    }

                    if (cItem.QS_CID < 0)
                    {
                        //新增
                        cItem.CreateTime   = DateTime.Now;
                        cItem.CreateUserID = userID;
                        int retCID = BLL.QS_Category.Instance.Insert(tran, cItem);

                        #region 修改各个表的分类ID

                        foreach (Entities.QS_Item iItem in QsItemList)
                        {
                            if (iItem.QS_CID == cItem.QS_CID)
                            {
                                iItem.QS_CID = retCID;
                            }
                        }

                        foreach (Entities.QS_Standard sItem in QsStandardList)
                        {
                            if (sItem.QS_CID == cItem.QS_CID)
                            {
                                sItem.QS_CID = retCID;
                            }
                        }

                        foreach (Entities.QS_Marking mItem in QsMarkingList)
                        {
                            if (mItem.QS_CID == cItem.QS_CID)
                            {
                                mItem.QS_CID = retCID;
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Category.Instance.Update(tran, cItem);
                    }
                }

                #endregion

                #region 保存项目

                foreach (Entities.QS_Item iItem in QsItemList)
                {
                    if (iItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Item.Instance.Delete(tran, iItem.QS_IID);
                        continue;
                    }

                    if (iItem.QS_IID < 0)
                    {
                        //新增
                        iItem.CreateTime   = DateTime.Now;
                        iItem.CreateUserID = userID;
                        int retIID = BLL.QS_Item.Instance.Insert(tran, iItem);

                        #region 修改各个表的项目ID

                        foreach (Entities.QS_Standard sItem in QsStandardList)
                        {
                            if (sItem.QS_IID == iItem.QS_IID)
                            {
                                sItem.QS_IID = retIID;
                            }
                        }

                        foreach (Entities.QS_Marking mItem in QsMarkingList)
                        {
                            if (mItem.QS_IID == iItem.QS_IID)
                            {
                                mItem.QS_IID = retIID;
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Item.Instance.Update(tran, iItem);
                    }
                }

                #endregion

                #region 保存质检标准

                foreach (Entities.QS_Standard sItem in QsStandardList)
                {
                    if (sItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Standard.Instance.Delete(tran, sItem.QS_SID);
                        continue;
                    }

                    if (sItem.QS_SID < 0 || (sItem.ScoreType == 3 && sItem.QS_SID <= 5))
                    {
                        //新增
                        sItem.CreateTime   = DateTime.Now;
                        sItem.CreateUserID = userID;
                        int retSID = BLL.QS_Standard.Instance.Insert(tran, sItem);

                        #region 修改各个表的项目ID
                        if (sItem.ScoreType != 3)
                        {
                            foreach (Entities.QS_Marking mItem in QsMarkingList)
                            {
                                if (mItem.QS_SID == sItem.QS_SID)
                                {
                                    mItem.QS_SID = retSID;
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Standard.Instance.Update(tran, sItem);
                    }
                }

                #endregion

                #region 保存评分扣分项

                foreach (Entities.QS_Marking mItem in QsMarkingList)
                {
                    if (mItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Marking.Instance.Delete(tran, mItem.QS_MID);
                        continue;
                    }

                    if (mItem.QS_MID < 0)
                    {
                        //新增
                        mItem.CreateTime   = DateTime.Now;
                        mItem.CreateUserID = userID;
                        BLL.QS_Marking.Instance.Insert(tran, mItem);
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Marking.Instance.Update(tran, mItem);
                    }
                }

                #endregion

                #region 保存致命项

                foreach (Entities.QS_DeadOrAppraisal dItem in QsDeadList)
                {
                    if (dItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_DeadOrAppraisal.Instance.Delete(tran, dItem.QS_DAID);
                        continue;
                    }

                    if (dItem.QS_DAID < 0)
                    {
                        //新增
                        dItem.CreateTime   = DateTime.Now;
                        dItem.CreateUserID = userID;
                        BLL.QS_DeadOrAppraisal.Instance.Insert(tran, dItem);
                    }
                    else
                    {
                        //编辑
                        BLL.QS_DeadOrAppraisal.Instance.Update(tran, dItem);
                    }
                }

                #endregion

                //add by qizq 保存日志 2013-5-8
                BLL.Util.InsertUserLog(tran, sbStr.ToString());

                tran.Commit();
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }


            #endregion
        }