Esempio n. 1
0
        /// <summary>
        /// 导入客户数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public JsonResult ImportCusData(string data)
        {
            string jsonStr = string.Empty;
            bool   result  = false;
            string retmsg  = string.Empty;

            DataDAL biz = new DataDAL();

            RetMsg msg = biz.DataImport(customerUrl, data, SessionId);

            if (!msg.IsSysError)
            {
                ImportResponse <CustomerErrorDetail> response = DataJsonSerializer <ImportResponse <CustomerErrorDetail> > .JsonToEntity(msg.Message);

                if (response.Data.FalseCount == 0)
                {
                    result = true; //导入成功
                }
                else
                {
                    jsonStr = JsonConvert.SerializeObject(response.Data);
                }
            }
            else
            {
                retmsg = msg.Message;
            }

            return(Json(new { Result = result, Msg = retmsg, Data = jsonStr }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
 public ActionResult Delete(string MineCode, string SensorNum)
 {
     try
     {
         if (!string.IsNullOrEmpty(MineCode) && !string.IsNullOrEmpty(SensorNum))
         {
             string[]      MineCodes  = MineCode.Split(new char[] { ',' });
             string[]      SensorNums = SensorNum.Split(new char[] { ',' });
             List <string> sql        = new List <string>();
             for (int i = 0; i < MineCodes.Length; i++)
             {
                 sql.Add(string.Format("delete from  LDKZ where MineCode='{0}' and SensorNums='{1}'", MineCodes[i], SensorNums[i]));
             }
             var  dal   = new DataDAL();
             bool resul = dal.ExcuteSqls(sql);
             if (resul)
             {
                 return(Json(new { data = "删除成功" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { data = "删除失败,请检查数据" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { data = "删除失败,无需删除的数据" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         return(Json(new { data = e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 3
0
        public ActionResult HisTraceShow(string MineCode)
        {
            LoadModel loadModel = new LoadModel();

            loadModel.UserMineCode = MineCode;
            string sql = "select filename, FileID from G_DPicFile";

            con         = Get128Con();
            ViewBag.Url = "";
            DataTable dt  = null;
            var       dal = new DataDAL();

            try
            {
                string json = "";
                dt = dal.ReturnData(sql, con);

                if (dt.Rows.Count > 0)
                {
                    loadModel.FileID = dt.Rows[0]["FileID"].ToString();
                    string fo = dt.Rows[0]["filename"].ToString();
                    fo          = fo.Substring(fo.LastIndexOf("."), fo.Length - fo.LastIndexOf("."));
                    ViewBag.Url = "temp" + fo;
                }
            }
            catch (Exception e)  { }
            return(View(loadModel));
        }
Esempio n. 4
0
        public void GetAlarmPageData(string mineCode)
        {
            Response.Buffer          = true;
            Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            Response.Expires         = 0;
            Response.CacheControl    = "no-cache";
            Response.AddHeader("Pragma", "No-Cache");

            string queryString = string.Empty;

            if (!string.IsNullOrEmpty(mineCode) && mineCode.ToLower() != "null")
            {
                queryString = string.Format(" Where MineCode Like '%{0}%'", mineCode);
            }
            else
            {
                queryString = "";
            }
            string sql = string.Format(@"select * from (Select mc.MineCode,mc.SimpleName,case sc.TypeCode when 1 then '安全监控系统' when 2 then '人员管理系统' when 3 then '瓦斯抽放系统' when 5 then '矿山压力系统' when 7 then '火灾束管系统' else '安全监控/瓦斯抽放系统' end as systemName,
case sc.StateCode when 1 then '通讯中断' when 2 then '传输异常'end as communicationState 
  from SystemConfig sc left join MineConfig mc on sc.MineCode=mc.ID where sc.StateCode<>0 ) as A {0}

/*安全监控报警*/
select * from (select mc.MineCode,mc.SimpleName MineName,dt.TypeName deviceName,aqss.Place,
case aqss.ValueState When 1 Then '报警' When 4 Then '断电报警' When 8 Then '故障报警' When 16 Then '馈电异常' Else '工作异常' end as AlarmType,
ShowValue,aqss.PoliceMaxValue,AQSS.SystemType, aqss.PoliceMaxDatetime,aqss.PowerMax,aqss.PowerMaxDatetime,aqss.PowerDateTime,aqss.PoliceDateTime,[dbo].[FunConvertTime](datediff(second, PoliceDatetime,getdate())) as PoliceContinuoustime,
[dbo].[FunConvertTime](datediff(second, PowerDateTime,getdate())) as PowerContinuoustime,[dbo].[FunConvertTime](datediff(second, PowerDateTime,getdate())) as AbnormalContinuoustime,
aqss.AbnormalDateTime
from (select * from aqss where ValueState<>0) as aqss  
left join DeviceType dt on AQSS.Type=dt.TypeCode 
left join MineConfig mc on aqss.MineCode=mc.MineCode ) as B {0}  Order by AlarmType   

/*人员管理超时报警*/
select * from (select mc.MineCode,mc.SimpleName,rycs.JobCardCode,ryxx.Name,RYXX.Position Post,RYXX.Department Dept,rycs.InTime InMineTime,rycs.StartAlTime,
dbo.FunConvertTime(DateDiff(second,RYCS.StartAlTime,GETDATE())) OverTimeLength 
from RYCS 
left join MineConfig mc on rycs.MineCode=mc.MineCode 
left join RYXX on RYCS.JobCardCode=RYXX.JobCardCode and RYCS.MineCode=RYXX.MineCode ) as C {0}

/*人员管理超员报警*/
select * from (select mc.MineCode,mc.SimpleName,xx.Name,xx.Position Post,xx.Department Dept,cy.Number LimiteNumber,cy.[Sum] RealNumber
,cy.[Type] AlarmType,cy.InTime InMineTime,cy.StartAlTime,dbo.FunConvertTime(DateDiff(second,cy.StartAlTime,GETDATE())) OverTimeLength  
from RYCYXZ cy 
left join RYXX xx on cy.MineCode=xx.MineCode and cy.JobCardCode=xx.JobCardCode 
left join MineConfig mc on cy.MineCode=xx.MineCode ) as D {0}

/*人员管理特种工作异常报警*/
select * from (select mc.MineCode,mc.SimpleName,xx.Name,xx.Position Post,xx.Department Dept,tz.InTime InMineTime,tz.OrigAddress PlanReachPlace,tz.OrigTime PlanReachTime,tz.RealTime RealReachTime,tz.[State] NowState 
from RYTZYC tz 
left join RYXX xx on tz.MineCode=xx.MineCode and tz.JobCardCode=xx.JobCardCode 
left join MineConfig mc on tz.MineCode=mc.MineCode ) as E {0}
", queryString);

            var dal  = new DataDAL();
            var dt   = dal.ReturnDs(sql);
            var data = JsonConvert.SerializeObject(dt);

            Response.Write(data);
            Response.End();
        }
Esempio n. 5
0
        public string  ShowPeople(string StationHeadID)
        {
            DataTable dt  = new DataTable();
            var       dal = new DataDAL();

            try{
                string sql = string.Format("select  Row_Number() over (order by EmpNo asc) as  TmpID ,  A.StationHeadID,C.DeptName,c.EmpName,C.EmpNo,A.InAntennaPlace,A.InStationHeadTime " +
                                           "  from dbo.RT_InStationHeadInfo A,RT_InOutMine B,Emp_Info C " +
                                           "  where A.CodeSenderAddress=B.CodeSenderAddress  and C.EmpID=A.UserID and A.StationHeadID={0} ", StationHeadID);

                dt = dal.ReturnData(sql, con);
                string json = "";

                if (dt != null)
                {
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                    };
                    json = "{\"total\":" + dt.Rows.Count + ",\"rows\":" + JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, timeConverter) + "}";
                }
                else
                {
                    json = "{}";
                }
                return(json);
            }


            catch (Exception e)
            {
                return("{}");
            }
        }
Esempio n. 6
0
        public void LoadComboGraph(string IP)
        {
            string sql = "select FileID,FileName from G_DPicFile";

            DataTable dt  = null;
            var       dal = new DataDAL();

            try
            {
                string json = "";
                dt = dal.ReturnData(sql, con);
                string ReturnString = "";
                if (dt.Rows.Count > 0)
                {
                    string TotalRows = dt.Rows.Count.ToString();;
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                    };
                    json         = JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, timeConverter);
                    ReturnString = "{\"total\": " + TotalRows + ",\"rows\":" + json + "}";
                }
                else
                {
                    ReturnString = "{\"total\":0,\"rows\":[]}";
                }

                Response.Write(ReturnString);
                Response.Flush();
                Response.End();
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 根据帐户 Id 获取报警设置状态
        /// </summary>
        /// <param name="accountId"></param>
        public void GetAlarmSetState(string accountId)
        {
            try
            {
                Response.Buffer          = true;
                Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                Response.Expires         = 0;
                Response.CacheControl    = "no-cache";
                Response.AddHeader("Pragma", "No-Cache");

                string sql =
                    string.Format(@"Select AlarmType, T.AlarmGroup, IsNull([Disabled], 1) [Disabled] From dbo.AlarmTypeInfo T
	Left Join 
	(Select * From dbo.AlarmSet Where AccountId = '{0}') S
	On T.AlarmType = S.LinkData"    , accountId);

                var dal  = new DataDAL();
                var dt   = dal.ReturnData(sql);
                var data = JsonConvert.SerializeObject(dt);

                Response.Write(data);
                Response.End();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 8
0
        public string LoadPerson()
        {
            string    sql  = "select EmpID,EmpNo,EmpName,DeptName from Emp_Info";
            DataTable dt   = null;
            var       dal  = new DataDAL();
            string    json = "{\"total\":";

            try
            {
                dt = dal.ReturnData(sql, con);
                if (dt.Rows.Count > 0)
                {
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                    };

                    json += dt.Rows.Count + ",\"rows\":" + JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, timeConverter) + "}";
                }
                else
                {
                    json = "{\"total\":0,\"rows\":[]}";
                }
            }
            catch (Exception e)  {    }
            return(json);
        }
        public string GetLoginDetails(string userName, string password)
        {
            bool data = false;
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    DataTable dt = new DataDAL().UserLogin(userName, password);

                    if (dt.Rows.Count > 0)
                    {
                        Session["UserID"]   = dt.Rows[0].Field <int>("UserID");
                        Session["UserName"] = userName;

                        data = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogging.SaveException(ex);
            }

            string jsonData = js.Serialize(data);

            return(jsonData);
        }
        public string UserRegisetration(string userName, string password, string emailAddress)
        {
            bool data = false;
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(password))
                {
                    DataTable dt = new DataDAL().GetUserByUserName(userName);

                    if (dt.Rows.Count == 0)
                    {
                        new DataDAL().InsertRegisteredUser(userName, password, emailAddress);

                        data = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogging.SaveException(ex);
            }

            string jsonData = js.Serialize(data);

            return(jsonData);
        }
Esempio n. 11
0
        ///获取当前下井人数
        public ActionResult LoadXJRS(string MineCode)
        {
            string sql = "select isnull(count(1),0)  Counts from ryss where inouttype=1 ";

            if (!string.IsNullOrEmpty(MineCode))
            {
                sql += " and MineCode ='" + MineCode + "'";
            }
            try{
                var dal = new DataDAL();
                var dt  = dal.ReturnData(sql);
                if (dt.Rows.Count > 0)
                {
                    return(Json(new { data = dt.Rows[0][0].ToString() }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { data = 0 }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(new { data = "Error!" }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 12
0
        public void QuerySysTypes()
        {
            DataDAL dal = new DataDAL();

            Response.Write(JsonConvert.SerializeObject(dal.ReturnData("Select * From dbo.SystemTypesInfo")));
            Response.End();
        }
Esempio n. 13
0
 public service(DataContext db, UserManager <User> userManager, RoleManager <IdentityRole> roleManager, IConfiguration configuration)
 {
     dal = new DataDAL(db, userManager, roleManager, configuration);
     this.userManager = userManager;
     this.roleManager = roleManager;
     _configuration   = configuration;
     jdal             = new JobDAL(db);
 }
Esempio n. 14
0
        public void LoadComboOver(string FileID)
        {
            log    log = new Controllers.log();
            string sql = "select  ConfigFile from G_DConfigFile ";

            if (!string.IsNullOrEmpty(FileID))
            {
                sql += " where MapfileID='" + FileID + "'";
            }

            DataTable dt  = null;
            var       dal = new DataDAL();

            try
            {
                string json = "";
                dt = dal.ReturnData(sql, con);
                log.WriteTextLog("行数:" + dt.Rows.Count, DateTime.Now);
                if (dt.Rows.Count > 0)
                {
                    byte[]      xmlbytes  = (byte[])dt.Rows[0]["ConfigFile"];
                    XmlDocument ConfigXml = G_D.BytesToXml(xmlbytes);
                    XmlNode     OverGraph = ConfigXml.SelectSingleNode("//Divs");
                    if (OverGraph.ChildNodes.Count > 0)
                    {
                        json += "{\"total\":" + OverGraph.ChildNodes.Count + ",\"rows\":[";
                        for (int i = 0; i < OverGraph.ChildNodes.Count; i++)
                        {
                            json += "{\"ID\":\"" + i + "\",\"FileName\":\"" + ConfigXml.SelectSingleNode("//Divs").ChildNodes[i].InnerText + "\"}";
                            if (i != OverGraph.ChildNodes.Count - 1)
                            {
                                json += ",";
                            }
                        }
                        json += "]}";
                    }
                }
                if (!string.IsNullOrEmpty(json))
                {
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    json = "{\"total\":0,\"rows\":[]}";
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                }
            }
            catch (Exception e)
            {
                log.WriteTextLog("Exception:" + e.Message, DateTime.Now);
            }
        }
Esempio n. 15
0
        public void FindPlaceD(string mineCode, string sensorNum)
        {
            string sql  = string.Format("select Place from AQKC where MineCode={0} and sensorNum='{1}'", mineCode, sensorNum);
            var    dal  = new DataDAL();
            var    dt   = dal.ReturnDs(sql);
            var    data = JsonConvert.SerializeObject(dt);

            Response.Write(data);


            Response.End();
        }
Esempio n. 16
0
        public void LoadALLOver()
        {
            string      sql       = "select c.ConfigFile,p.Fileimg from G_DConfigFile c  left join  G_DPicFile p on c.MapFileID= p.FileID";
            string      result    = "";
            DataTable   dt        = new DataTable();
            var         dal       = new DataDAL();
            XmlDocument ConfigXml = null;

            byte[]      xmlbytes = null;
            XmlNodeList xnl      = null;

            string[]    OverList = null;
            XmlNodeList filename = null;
            string      list     = "";

            try
            {
                dt = dal.ReturnData(sql, con);
                if (dt.Rows.Count > 0)
                {
                    xmlbytes  = (byte[])dt.Rows[0]["ConfigFile"];
                    ConfigXml = G_D.BytesToXml(xmlbytes);
                    xnl       = ConfigXml.SelectSingleNode("//Stations").ChildNodes;
                    filename  = ConfigXml.SelectSingleNode("//Divs").ChildNodes;

                    for (int i = 0; i < filename.Count; i++)
                    {
                        if (i != filename.Count - 1)
                        {
                            list += filename[i].InnerText.ToString() + ",";
                        }
                        else
                        {
                            list += filename[i].InnerText.ToString();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(list))
                {
                    OverList = list.Split(new char[] { ',' });
                }

                result = ReadStation(xnl, OverList);
            }

            catch (Exception e)
            {
            }
            Response.Write(result);
            Response.Flush();
            Response.End();
        }
Esempio n. 17
0
        public void SetAlarmSetItem(string accountId, string alarmGroup, string disabled, string linkData)
        {
            Response.Buffer          = true;
            Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            Response.Expires         = 0;
            Response.CacheControl    = "no-cache";
            Response.AddHeader("Pragma", "No-Cache");
            string sql;

            if (alarmGroup.Equals("99"))
            {
                sql  = string.Format(@"Delete From [ShineView_Data].[dbo].[AlarmSet] Where [AccountId] = '{0}' And [AlarmGroup] = {1} And [LinkData] = '{2}' ", accountId, alarmGroup, linkData);
                sql += string.Format(@"INSERT INTO [ShineView_Data].[dbo].[AlarmSet]([AccountId],[AlarmGroup],[Disabled],[LinkData])VALUES('{0}', {1},{2},'{3}') ", accountId, alarmGroup, disabled, linkData);
            }
            else
            {
                sql = string.Format(@"Delete From [ShineView_Data].[dbo].[AlarmSet] Where [AccountId] = '{0}' And [AlarmGroup] = {1} And [LinkData] = '{2}' ", accountId, alarmGroup, linkData);
                //event before is  false ;  event have been is  true;
                //if (disabled.Equals("false")) //
                {
                    sql += string.Format(@"INSERT INTO [ShineView_Data].[dbo].[AlarmSet]([AccountId],[AlarmGroup],[Disabled],[LinkData])VALUES('{0}', {1},{2},'{3}') ", accountId, alarmGroup, disabled.Equals("true") ? 1 : 0, linkData);
                }
            }

            var dal = new DataDAL();

            if (dal.ExcuteSql(sql))
            {
                if (!disabled.Equals("true"))
                {
                    Response.Write(string.Format("{0} 更新成功, 状态为报警", linkData));
                }
                else
                {
                    Response.Write(string.Format("{0} 更新成功, 状态为不报警", linkData));
                }
            }
            else
            {
                if (!disabled.Equals("true"))
                {
                    Response.Write(string.Format("{0} 更新失败, 状态为报警", linkData));
                }
                else
                {
                    Response.Write(string.Format("{0} 更新失败, 状态为不报警", linkData));
                }
            }

            Response.End();
        }
        public string GetDataForAngularGrid()
        {
            DataTable dt = new DataTable();

            try
            {
                dt = new DataDAL().GetDepartmentsUsers();
            }
            catch (Exception ex)
            {
                ExceptionLogging.SaveException(ex);
            }

            return(Utility.DataTableToJSONWithJSONNet(dt));
        }
Esempio n. 19
0
        public ActionResult LoadRate(string FileID)
        {
            string sql    = "";
            string fileID = "";

            if (!string.IsNullOrEmpty(FileID))
            {
                sql = string.Format("select FileImg,FileID from G_DPicFile where fILEid='{0}'", FileID);
            }
            else
            {
                sql = string.Format("select top(1) FileImg,FileID from G_DPicFile");
            }

            DataTable dt  = null;
            var       dal = new DataDAL();

            try
            {
                dt = dal.ReturnData(sql, con);
                byte[] xmlbytes = null;
                if (dt.Rows.Count > 0)
                {
                    fileID = dt.Rows[0]["FileID"].ToString();
                    if (!string.IsNullOrEmpty(dt.Rows[0]["FileImg"].ToString()))
                    {
                        xmlbytes = (byte[])dt.Rows[0]["FileImg"];
                        // 可行
                        Image img = byteArrayToImage(xmlbytes);
                        return(Json(new { width = img.Width, height = img.Height, State = 1 }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { State = 0 }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { State = 0 }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(new { State = 2 }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 20
0
        public bool IsExist(string MineCode, string SensorNums)
        {
            bool Success = false;

            string    sql = string.Format("select * from LDKZ where MineCode='{0}' and SensorNums='{1}'", MineCode, SensorNums);
            var       dal = new DataDAL();
            DataTable dt  = null;

            try
            {
                dt = dal.ReturnData(sql);
                if (dt.Rows.Count > 0)
                {
                    Success = true;
                }
            }
            catch (Exception e) { }
            return(Success);
        }
Esempio n. 21
0
        public void LoadOverGraph(string FileID, string FileName)
        {
            string Sql = "";

            string      sql       = "select ConfigFile from G_DConfigFile ";
            string      result    = "";
            DataTable   dt        = null;
            var         dal       = new DataDAL();
            XmlDocument ConfigXml = null;

            byte[]      xmlbytes = null;
            XmlNodeList xnl      = null;

            string[] OverList = null;
            try
            {
                if (!string.IsNullOrEmpty(FileID))
                {
                    sql += " Where MapFileID='" + FileID + "'";

                    dt = dal.ReturnData(sql, con);

                    if (dt.Rows.Count > 0)
                    {
                        xmlbytes  = (byte[])dt.Rows[0]["ConfigFile"];
                        ConfigXml = G_D.BytesToXml(xmlbytes);
                        xnl       = ConfigXml.SelectSingleNode("//Stations").ChildNodes;
                    }
                    if (!string.IsNullOrEmpty(FileName))
                    {
                        OverList = FileName.Split(new char[] { ',' });
                    }

                    result = ReadStation(xnl, OverList);
                }
            }
            catch (Exception e)
            {
            }
            Response.Write(result);
            Response.Flush();
            Response.End();
        }
        public string GetDataForDepartment()
        {
            DataTable dt = new DataTable();

            try
            {
                dt = new DataDAL().GetDepartments();

                //DataRow dr = dt.NewRow();
                //dr["DepartmentName"] = "Select";
                //dr["DepartmentID"] = "0";
                //dt.Rows.InsertAt(dr, 0);
            }
            catch (Exception ex)
            {
                ExceptionLogging.SaveException(ex);
            }

            return(Utility.DataTableToJSONWithJSONNet(dt));
        }
Esempio n. 23
0
        public string LoadChildTypeName(string mineCode, string Type, string SysCode)
        {
            string sql = "select distinct  EquipName TypeName ,Unit,EquipType,case  EquipType when 0 then '模拟量' when 1 then '开关量' when 2 then '累积量' end as Type  from " + SysCode + "_Equipment ";

            if (!string.IsNullOrEmpty(Type))
            {
                sql += " where  EquipType=" + Type;
            }
            try{
                sql += " order by EquipType";
                DataTable dt = new DataDAL().ReturnData(sql);

                int    total = dt.Rows.Count;
                string json  = JsonConvert.SerializeObject(dt, Formatting.Indented);
                json = "{\"total\": " + total + ",\"rows\":" + json + "}";
                return(json);
            }
            catch (Exception e)
            {
                return("");
            }
        }
Esempio n. 24
0
        public string LoadChildSensor(string mineCode, string Type, string SysCode)
        {
            string sql = "select tp.PointID SensorNum ,tp.PointName SensorName ,EquipPlace  Place,te.EquipName TypeName,te.Unit from " + SysCode + "_Points  tp left join " + SysCode + "_Equipment te " +
                         " on tp.EquipID=te.ID ";

            if (!string.IsNullOrEmpty(Type))
            {
                sql += " where te.EquipName='" + Type + "'";
            }
            try
            {
                DataTable dt    = new DataDAL().ReturnData(sql);
                int       total = dt.Rows.Count;
                string    json  = JsonConvert.SerializeObject(dt, Formatting.Indented);
                json = "{\"total\": " + total + ",\"rows\":" + json + "}";
                return(json);
            }
            catch (Exception e)
            {
                return("");
            }
        }
Esempio n. 25
0
        public JsonResult Login(FormCollection formCol)
        {
            string loginUrl = string.Empty;

            try
            {
                string domain = ConfigurationManager.AppSettings["domain"].ToString();
                loginUrl = string.Format(ConfigurationManager.AppSettings["loginUrl"].ToString(), domain);

                string userName = formCol["userName"];
                string Password = formCol["Password"];

                bool   result = false;
                string retmsg = string.Empty;

                userName = userName.Trim();
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Password))
                {
                    UserRequestEntity user = new UserRequestEntity();

                    user.userCode = userName;
                    user.passWord = Password;
                    user.type     = 1;
                    user.sysInfo  = "web";

                    DataDAL biz = new DataDAL();

                    UserResponseEntity response = new UserResponseEntity();

                    RetMsg msg = biz.GetUserInfo(loginUrl, user);

                    if (!msg.IsSysError)
                    {
                        response = DataJsonSerializer <UserResponseEntity> .JsonToEntity(msg.Message);

                        if (response.StatusCode == 200)
                        {
                            Session["userCode"]  = response.Data.UserCode;
                            Session["userName"]  = response.Data.UserName;
                            Session["SessionId"] = response.Data.SessionId;

                            result = true; //sessionId不为空,用户登录成功
                        }
                        else
                        {
                            retmsg = response.ErrorMsg;
                        }
                    }
                    else
                    {
                        retmsg = msg.Message;
                    }
                }
                else
                {
                    retmsg = "用户名和密码不能为空";
                }

                return(Json(new { Result = result, Msg = retmsg }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 26
0
        public DataInfo GetByKey(int rkey)
        {
            DataDAL dd = new DataDAL(_factoryID);

            return(dd.GetByKey(rkey));
        }
Esempio n. 27
0
        public DataTable GetDataSet(string sql)
        {
            DataDAL dd = new DataDAL(_factoryID);

            return(dd.GetDataSet(sql));
        }
Esempio n. 28
0
        public string getSerialNo(string type)
        {
            DataDAL dd = new DataDAL(_factoryID);

            return(dd.getSerialNo(type));
        }
Esempio n. 29
0
        /// <summary>
        /// 保存/提交 预警处理
        /// </summary>
        /// <param name="ID">该条预警的id</param>
        /// <param name="Recorder">记录人</param>
        /// <param name="Measure">处理措施</param>
        /// <param name="DealResult">处理结果</param>
        /// <param name="state">保存或提交,保存还存在原来表中,提交转存历史表</param>
        /// <returns></returns>
        public ActionResult SavePre(string Recorder, string Measure, string DealResult, string ID, string flag, string Operate)
        {
            // flag 为报警是否结束 0为结束1为未结束

            //将输入文字中的单引号变为双引号,防止插入失败
            if (!string.IsNullOrEmpty(Recorder))
            {
                Recorder = Recorder.Replace("'", "\"");
            }
            if (!string.IsNullOrEmpty(Measure))
            {
                Measure = Measure.Replace("'", "\"");
                //Measure.Replace("'", "\"");
            }
            if (!string.IsNullOrEmpty(DealResult))
            {
                DealResult = DealResult.Replace("'", "\"");
            }

            string sql      = string.Format(@"update  warnalarm  set jlpers='{0}',chulway='{1}',chulresult='{2}',jltime='{3}' where ID={4} ", Recorder, Measure, DealResult, DateTime.Now, ID);
            bool   IsUpdate = _mineCfgModel.Exec(sql);

            if (!IsUpdate)
            {
                return(Json(new { data = "保存失败,请检查数据库连接!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (flag == "1")
                {
                    return(Json(new { data = "保存成功!" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (Operate == "submit")
                    {
                        string sql_Select = "select w.minecode,w.sensornum,w.starttime,w.overtime,w.maxvalue,w.minvalue,w.lasttime,w.level,w.chulway,w.chulresult,w.jlpers,w.jltime ,w.chulStatus,m.simplename,m.city , c.place,c.unit,c.type from warnalarm w" +
                                            " left join mineconfig m on w.minecode=m.minecode " +
                                            " left join aqmc c on w.minecode=c.minecode and w.sensornum=c.sensornum  where w.id=" + ID;

                        var    dal        = new DataDAL();
                        var    dt         = dal.ReturnData(sql_Select);
                        string sql_Insert = string.Format("insert into shineview_his.dbo.[WarnAlarm_His] (MineCode,sensornum,starttime,overtime,maxvalue,minevalue,lasttime,level,chulway,chulresult,jlpers,jltime,status,mineName,city,place,unit,type,datetime) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}')", dt.Rows[0][0], dt.Rows[0][1], dt.Rows[0][2], dt.Rows[0][3], dt.Rows[0][4], dt.Rows[0][5], dt.Rows[0][6], dt.Rows[0][7], dt.Rows[0][8], dt.Rows[0][9], dt.Rows[0][10], dt.Rows[0][11], dt.Rows[0][12], dt.Rows[0][13], dt.Rows[0][14], dt.Rows[0][15], dt.Rows[0][16], dt.Rows[0][17], DateTime.Now);
                        bool   IsInsert   = dal.ExcuteSql(sql_Insert);

                        if (IsInsert)
                        {
                            string sql_Delete = string.Format("delete from WarnAlarm where id={0}", ID);
                            bool   IsDelete   = dal.ExcuteSql(sql_Delete);
                            if (IsDelete)
                            {
                                return(Json(new { data = "提交成功!" }, JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                return(Json(new { data = "删除数据失败,请检查数据库连接!" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            return(Json(new { data = "插入历史预警表失败,请检查数据库连接。" }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json(new { data = "保存成功!该报警已结束,请及时提交。" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 加载所有煤矿报警统计信息
        /// </summary>
        /// <param name="mineCode">煤矿编号</param>
        public void GetAllAlarmCount(string mineCode)
        {
            try
            {
                Response.Buffer          = true;
                Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                Response.Expires         = 0;
                Response.CacheControl    = "no-cache";
                Response.AddHeader("Pragma", "No-Cache");

                string queryString = string.Empty;

                if (!string.IsNullOrEmpty(mineCode) && mineCode.ToLower() != "null")
                {
                    queryString = string.Format(" Where MineCode Like '%{0}%'", mineCode);
                }
                else
                {
                    queryString = "";
                }

                string sql = string.Format(@"With U As(
	Select * From (
        -- 基站报警
        select '分站停用' AlarmType, MineCode,'人员管理系统' AlarmGroup,Place SensorName From  RYFZ where StationState=1

        union ALL
        select '分站检修' AlarmType, MineCode,'人员管理系统' AlarmGroup,Place SensorName From  RYFZ where StationState=2
        union all
		-- 人员管理报警信息
		Select '超时报警' AlarmType, MineCode,'人员管理系统' AlarmGroup,'人员管理系统' SensorName From RYCS 
		Union All 
		Select '特种人员工作异常报警' AlarmType, MineCode,'人员管理系统' AlarmGroup,'人员管理系统' SensorName From RYTZYC
		Union All 
		Select '超员报警' AlarmType, MineCode,'人员管理系统' AlarmGroup,'人员管理系统' SensorName From RYCYXZ 
		Union All
		-- 安全监控报警信息
		Select case A.ValueState When 1 Then '报警' When 4 Then '断电报警' When 8 Then '故障报警' When 16 Then '馈电异常报警' Else '工作异常报警' End AlarmType,
			A.MineCode, '安全监控系统' as AlarmGroup, dt.TypeName SensorName From (Select MineCode,ValueState,[type] from Aqss where ValueState!=0) As A 
			Left Join [dbo].[DeviceType] dt on A.[type]=dt.TypeCode Left Join MineConfig mc on A.MineCode=mc.MineCode
	) As U 
)
Select COUNT(1) As AlarmCount From
(
	--通讯状态报警信息
	Select SimpleName, Case [StateCode] When 1 Then '通讯中断报警' When 2 Then '传输异常报警' End AlarmType, M.MineCode, Name AlarmGroup, '' SensorName
		From (
       Select * From SystemConfig S Where StateCode <> 0) S
		Left Join MineConfig M On S.MineCode = M.ID 
	Union All
	-- 人员管理及安全监控报警信息
	Select SimpleName, AlarmType, M.MineCode, U.AlarmGroup, U.SensorName From U Left Join MineConfig M On U.MineCode = M.MineCode 
		--Where U.MineCode Not In (Select M.MineCode From SystemConfig S Left Join MineConfig M On S.MineCode = M.ID Where StateCode <> 0)
) As U {0}
", queryString);

                var dal  = new DataDAL();
                var dt   = dal.ReturnData(sql);
                var data = JsonConvert.SerializeObject(dt);

                Response.Write(data);
                Response.End();
            }
            catch (Exception)
            {
            }
        }