Example #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, CarinfoEntity entity, string pitem, string url)
 {
     try
     {
         var    data = dataItemservice.GetDataItemListByItemCode("'SocketUrl'");
         string IP   = "";
         int    Port = 0;
         foreach (var item in data)
         {
             if (item.ItemName == "IP")
             {
                 IP = item.ItemValue;
             }
             else if (item.ItemName == "Port")
             {
                 Port = Convert.ToInt32(item.ItemValue);
             }
         }
         service.SaveForm(keyValue, entity, pitem, url, IP, Port);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        public ActionResult SaveForm(string keyValue, CarinfoEntity entity)
        {
            DataItemDetailBLL pdata = new DataItemDetailBLL();
            var pitem = pdata.GetItemValue("Hikappkey");  //海康服务器密钥
            var url   = pdata.GetItemValue("HikBaseUrl"); //海康服务器地址

            carinfobll.SaveForm(keyValue, entity, pitem, url);
            return(Success("操作成功。"));
        }
Example #3
0
 /// <summary>
 /// 修改海康车辆信息
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="OldCar"></param>
 public void UpdateHiaKangCar(CarinfoEntity entity, string OldCar)
 {
     try
     {
         service.UpdateHiaKangCar(entity, OldCar);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #4
0
 public void CartoExamine(string keyValue, CarinfoEntity entity)
 {
     try
     {
         service.CartoExamine(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #5
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue"></param>
 /// <param name="entity"></param>
 public void SaveForm(string keyValue, CarinfoEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #6
0
        /// <summary>
        /// 增加一个违章接口
        /// </summary>
        public void AddViolation(string id, int type, int ViolationType, string ViolationMsg)
        {
            CarviolationEntity entity = new CarviolationEntity();

            //0为电厂班车 1为私家车 2为商务公车 3为拜访车辆 4为物料车辆 5为危化品车辆
            switch (type)
            {
            case 0:
            case 1:
            case 2:
                Repository <CarinfoEntity> inlogdbC = new Repository <CarinfoEntity>(DbFactory.Base());
                CarinfoEntity car = inlogdbC.FindEntity(id);
                entity.CardNo = car.CarNo;
                entity.Dirver = car.Dirver;
                entity.Phone  = car.Phone;
                break;

            case 3:
                Repository <VisitcarEntity> inlogdbv = new Repository <VisitcarEntity>(DbFactory.Base());
                VisitcarEntity oldv = inlogdbv.FindEntity(id);
                entity.CardNo = oldv.CarNo;
                entity.Dirver = oldv.Dirver;
                entity.Phone  = oldv.Phone;
                break;

            case 4:
                Repository <OperticketmanagerEntity> inlogdbo = new Repository <OperticketmanagerEntity>(DbFactory.Base());
                OperticketmanagerEntity oldo = inlogdbo.FindEntity(id);
                entity.CardNo = oldo.Platenumber;
                entity.Dirver = oldo.DriverName;
                entity.Phone  = oldo.DriverTel;
                break;

            case 5:
                Repository <HazardouscarEntity> inlogdb = new Repository <HazardouscarEntity>(DbFactory.Base());
                HazardouscarEntity old = inlogdb.FindEntity(id);

                entity.CardNo = old.CarNo;
                entity.Dirver = old.Dirver;
                entity.Phone  = old.Phone;
                break;
            }
            entity.CarType       = type;
            entity.CID           = id;
            entity.ViolationType = ViolationType;
            entity.ViolationMsg  = ViolationMsg;
            entity.IsProcess     = 0;
            entity.Create();
            this.BaseRepository().Insert(entity);
        }
        public ActionResult GetUserDetails()
        {
            List <CarinfoEntity> userlist = new List <CarinfoEntity>();
            string    sql = string.Format(@"select 
             u.userid,Account,senddeptid,REALNAME,MOBILE,OrganizeName,DEPTNAME,DUTYNAME,POSTNAME,usertype,GENDER,OrganizeCode,CreateDate,isblack,identifyid,score,IsPresence,realname as username,DEPARTURETIME,u.deptcode,nature,u.DEPARTMENTCODE,organizeid,u.IsTransfer,u.DepartureReason,u.fourpersontype,1 isleave,IsEpiboly
             from 
             v_userinfo u left join (select a.userid,sum(score) as score from base_user a left join bis_userscore b on a.userid=b.userid where year='{0}' group by a.userid) t on u.userid=t.userid
             where Account!='System' and u.EnabledMark=1", DateTime.Now.Year);
            DataTable dt  = departmentBLL.GetDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    CarinfoEntity entity = new CarinfoEntity();
                    entity.Dirver   = dr["username"].ToString();
                    entity.Phone    = dr["MOBILE"].ToString();
                    entity.Remark   = dr["DEPTNAME"].ToString();//单位
                    entity.DirverId = dr["userid"].ToString();

                    DataTable dt1 = departmentBLL.GetDataTable(string.Format("select fullname from BASE_DEPARTMENT where encode=(select encode from BASE_DEPARTMENT t where instr('{0}',encode)=1 and nature='{1}' and organizeid='{2}') or encode='{0}' order by deptcode", dr["DEPARTMENTCODE"], "部门", dr["organizeid"]));
                    if (dt1.Rows.Count > 0)
                    {
                        string name = "";
                        foreach (DataRow dr1 in dt1.Rows)
                        {
                            name += dr1["fullname"].ToString() + "/";
                        }
                        //dr["deptname"] = name.TrimEnd('/');
                        if (name != null)
                        {
                            entity.Deptname = entity.Dirver + "-" + name.TrimEnd('/');
                        }
                        else
                        {
                            entity.Deptname = entity.Dirver;
                        }
                    }

                    userlist.Add(entity);
                }
            }
            return(Content(userlist.ToJson()));
        }
Example #8
0
        /// <summary>
        /// 私家车辆审核
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public ActionResult CartoExamine(string keyValue, CarinfoEntity entity)
        {
            var item = carinfobll.GetEntity(keyValue);

            if (item != null)
            {
                item.State  = entity.State;
                item.Remark = entity.Remark;
                if (item.State == "1")
                {
                    item.Starttime    = entity.Starttime;
                    item.Endtime      = entity.Endtime;
                    item.Currentgid   = entity.Currentgid;
                    item.Currentgname = entity.Currentgname;
                }
                carinfobll.CartoExamine(keyValue, item);
            }
            return(Success("操作成功。"));
        }
Example #9
0
        public string ImportData()
        {
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                DataTable            dt                = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName));
                int                  order             = 1;
                DataItemDetailBLL    dataItemDetailBLL = new DataItemDetailBLL();
                List <DataItemModel> data              = dataItemDetailBLL.GetDataItemListByItemCode("'CarNo'").ToList();


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //车牌号
                    string CarNo = dt.Rows[i][0].ToString();
                    //车辆品牌系列
                    string Model = dt.Rows[i][1].ToString();
                    ////驾驶人
                    //string Dirver = dt.Rows[i][2].ToString();
                    ////驾驶人电话
                    //string Phone = dt.Rows[i][3].ToString();
                    //最近年检日期
                    string Time = dt.Rows[i][2].ToString();
                    //起始时间
                    string StartTime = dt.Rows[i][3].ToString();
                    ////结束时间
                    string EndTime = dt.Rows[i][4].ToString();
                    //荷载人数
                    string Num = dt.Rows[i][5].ToString();

                    if (CarNo.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号为空,未能导入.";
                        error++;
                        continue;
                    }

                    CarNo = CarNo.Trim().ToUpper();//英文转换为大写


                    string s    = CarNo.Substring(0, 1);
                    bool   flag = false;
                    foreach (var d in data)
                    {
                        if (d.ItemName == s)
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (flag == false)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号输入格式错误,第一位请输入正确的省缩写,未能导入.";
                        error++;
                        continue;
                    }

                    //判断车牌号位数是否合法
                    if (!Regex.IsMatch(CarNo.Trim(), "(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$)"))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号填写错误,未能导入.";
                        error++;
                        continue;
                    }

                    if (Model.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "内部编号为空,未能导入.";
                        error++;
                        continue;
                    }
                    //if (Dirver.Trim() == "")
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "驾驶人为空,未能导入.";
                    //    error++;
                    //    continue;
                    //}
                    //if (Phone.Trim() == "")
                    //{
                    //    falseMessage += "</br>" + "第" + (i + 2) + "驾驶人电话为空,未能导入.";
                    //    error++;
                    //    continue;
                    //}
                    if (Time.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期为空,未能导入.";
                        error++;
                        continue;
                    }

                    if (StartTime.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "起始时间为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (EndTime.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "结束时间为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (Num.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "荷载人数为空,未能导入.";
                        error++;
                        continue;
                    }
                    DateTime dtime;
                    try
                    {
                        DateTime.TryParse(Time, out dtime);

                        if (dtime.ToString("yyyy-MM-dd") == "0001-01-01")
                        {
                            falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期格式不对,请输入yyyy-MM-dd格式,未能导入.";
                            error++;
                            continue;
                        }
                    }
                    catch (Exception e)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "最近年检日期格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }

                    DateTime Stime;


                    DateTime.TryParse(StartTime, out Stime);

                    if (Stime.ToString("yyyy-MM-dd") == "0001-01-01")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "起始时间格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }



                    DateTime Etime;


                    DateTime.TryParse(StartTime, out Etime);

                    if (Etime.ToString("yyyy-MM-dd") == "0001-01-01")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "结束时间格式不对,请输入yyyy-MM-dd格式,未能导入.";
                        error++;
                        continue;
                    }


                    if (carinfobll.GetCarNoIsRepeat(CarNo, ""))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号数据已存在,请勿重复录入.";
                        error++;
                        continue;
                    }

                    Etime = Convert.ToDateTime(Etime.ToString("yyyy-MM-dd 23:59:59"));
                    Stime = Convert.ToDateTime(Stime.ToString("yyyy-MM-dd 00:00:00"));

                    CarinfoEntity hf = new CarinfoEntity();
                    hf.CarNo   = CarNo.Trim();
                    hf.GpsId   = "";
                    hf.GpsName = "";
                    //hf.Dirver = Dirver;
                    hf.InsperctionDate = dtime;
                    hf.Model           = Model;
                    hf.NumberLimit     = Convert.ToInt32(Num);
                    hf.Endtime         = Etime;
                    hf.Starttime       = Stime;
                    //hf.Phone = Phone;
                    hf.NextInsperctionDate = dtime.AddDays(-1).AddYears(1);
                    hf.Type = 0;


                    try
                    {
                        DataItemDetailBLL pdata = new DataItemDetailBLL();
                        var pitem = pdata.GetItemValue("Hikappkey");  //海康服务器密钥
                        var url   = pdata.GetItemValue("HikBaseUrl"); //海康服务器地址
                        carinfobll.SaveForm("", hf, pitem, url);
                    }
                    catch
                    {
                        error++;
                    }
                }
                count    = dt.Rows.Count;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }
Example #10
0
        public string ImportData()
        {
            int    error        = 0;
            string message      = "请选择格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                DataTable            dt                = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName));
                int                  order             = 1;
                DataItemDetailBLL    dataItemDetailBLL = new DataItemDetailBLL();
                List <DataItemModel> data              = dataItemDetailBLL.GetDataItemListByItemCode("'CarNo'").ToList();

                UserBLL       userbll  = new UserBLL();
                DepartmentBLL deptbll  = new DepartmentBLL();
                var           userlist = userbll.GetList();
                var           deptList = deptbll.GetList();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //车牌号
                    string CarNo = dt.Rows[i][2].ToString().Trim();
                    //内部编号
                    string Model = dt.Rows[i][1].ToString();
                    //驾驶人
                    string Dirver = dt.Rows[i][3].ToString();
                    //驾驶人电话
                    string Phone = dt.Rows[i][4].ToString();
                    if (CarNo.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号为空,未能导入.";
                        error++;
                        continue;
                    }

                    CarNo = CarNo.Trim().ToUpper();//英文转换为大写


                    string s    = CarNo.Substring(0, 1);
                    bool   flag = false;
                    foreach (var d in data)
                    {
                        if (d.ItemName == s)
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (flag == false)
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号输入格式错误,第一位请输入正确的省缩写,未能导入.";
                        error++;
                        continue;
                    }

                    //判断车牌号位数是否合法
                    if (!Regex.IsMatch(CarNo.Trim(), "(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$)"))
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "车牌号填写错误,未能导入.";
                        error++;
                        continue;
                    }

                    if (Model.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "内部编号为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (Dirver.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "驾驶人为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (Phone.Trim() == "")
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "驾驶人电话为空,未能导入.";
                        error++;
                        continue;
                    }

                    var user = userlist.Where(it => it.Account == Phone).FirstOrDefault();
                    if (user != null)
                    {
                        DateTime Stime = Convert.ToDateTime("2020-09-22 00:00:00");
                        DateTime Etime = Convert.ToDateTime("2024-09-22 23:59:59");

                        CarinfoEntity hf = new CarinfoEntity();
                        hf.CarNo   = CarNo.Trim();
                        hf.GpsId   = "";
                        hf.GpsName = "";
                        //hf.Dirver = Dirver;
                        hf.State        = "1";
                        hf.Remark       = "";
                        hf.CreateUserId = user.UserId;
                        hf.Model        = Model;
                        hf.Dirver       = user.RealName;
                        hf.DirverId     = user.UserId;
                        hf.Phone        = user.Mobile;
                        var    dept     = deptList.Where(it => it.DepartmentId == user.DepartmentId).FirstOrDefault();
                        string deptname = "";
                        if (dept != null)
                        {
                            deptname = dept.FullName;
                        }
                        hf.Deptname     = deptname;
                        hf.IsAuthorized = 0;
                        hf.Endtime      = Etime;
                        hf.Starttime    = Stime;
                        hf.Type         = 1;


                        try
                        {
                            string sql     = string.Format(@"insert into bis_carinfo (ID, CREATEUSERID, CREATEDATE, MODIFYUSERID, MODIFYDATE, CREATEUSERDEPTCODE, CREATEUSERORGCODE, CARNO, DIRVER, PHONE, INSPERCTIONDATE, NEXTINSPERCTIONDATE, TYPE, NUMBERLIMIT, DRIVERLICENSEURL, DRIVINGLICENSEURL, MODEL, GPSID, GPSNAME, ISAUTHORIZED, AUTHUSERID, AUTHUSERNAME, STARTTIME, ENDTIME, STATE, CURRENTGNAME, CURRENTGID, REMARK, ISENABLE, DIRVERID, DEPTNAME)
values ('{0}', '{1}', '{2}', null, null, '{3}', '{4}', '{5}', '{6}', '{7}', null, null, {8}, null, null, null, '{9}', '', '', '{10}', '', '', '{11}', '{12}', '{13}', '1号岗', '2849d7a3cfbe4b64b35c9553f3861f10', '', 0, '{14}', '{15}');", Guid.NewGuid().ToString(), hf.CreateUserId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), user.DepartmentCode, user.OrganizeCode, hf.CarNo, hf.Dirver, hf.Phone, hf.Type, hf.Model, hf.IsAuthorized, hf.Starttime, hf.Endtime, hf.State, hf.DirverId, hf.Deptname);
                            string LogName = "PrivateCar.txt";
                            string Url     = "D:\\sql";
                            if (!System.IO.Directory.Exists(Url))
                            {
                                System.IO.Directory.CreateDirectory(Url);
                            }
                            System.IO.File.AppendAllText(Url + "\\" + LogName, sql + "\r\n");
                        }
                        catch
                        {
                            error++;
                        }
                    }
                    else
                    {
                        falseMessage += "</br>" + "第" + (i + 2) + "行为找到对应人员,未能导入.";
                        error++;
                        continue;
                    }
                }
                count    = dt.Rows.Count;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }

            return(message);
        }