示例#1
0
    public string GetMeterInfo(string key, string meterNo, out string info)
    {
        string reuslt = string.Empty;

        info = string.Empty;
        if (key != "6E5F0C851FD4" || string.IsNullOrEmpty(meterNo))
        {
            info = "参数有误!";
            return(reuslt);
        }
        try
        {
            var bc = new project.Business.Base.BusinessMeter();
            bc.load(meterNo);
            if (bc.Entity != null)
            {
                var obj = new { rmid = bc.Entity.MeterRMID, read = bc.Entity.MeterReadout.ToString("0.##"), digit = bc.Entity.MeterDigit };
                reuslt = JsonConvert.SerializeObject(obj);
            }
            else
            {
                info = "查无此表!";
            }
        }
        catch
        {
            info = "异常!";
        }
        return(reuslt);
    }
示例#2
0
        private string createList(string MeterLOCNo1, string MeterLOCNo2, string MeterLOCNo3, string MeterLOCNo4, string MeterNo, string MeterType, string MeterUsageType, string MeterRMID, string MeterSize, string MeterStatus, int page)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder("");

            sb.Append("<table class=\"table table-border table-bordered table-hover table-bg table-sort\" id=\"tablelist\">");
            sb.Append("<thead>");
            sb.Append("<tr class=\"text-c\">");
            sb.Append("<td width='4%' class=\"printck\"><input type=\"checkbox\" class=\"input-text size-MINI\" id=\"checkall\" onclick=\"getall()\" /></td>");
            sb.Append("<th width=\"5%\">序号</th>");
            sb.Append("<th width='13%'>房间编号</th>");
            sb.Append("<th width='10%'>表记编号</th>");
            sb.Append("<th width='10%'>表记名称</th>");
            sb.Append("<th width='16%'>园区/建设期/楼栋/楼层</th>");
            sb.Append("<th width='6%'>倍数</th>");
            sb.Append("<th width='6%'>位数</th>");
            sb.Append("<th width='8%'>使用类别</th>");
            sb.Append("<th width='9%'>当月读数</th>");
            sb.Append("<th width='10%'>读数日期</th>");
            sb.Append("<th width='7%'>状态</th>");
            sb.Append("</tr>");
            sb.Append("</thead>");

            int r = 1;

            sb.Append("<tbody>");
            Business.Base.BusinessMeter bc = new project.Business.Base.BusinessMeter();
            foreach (Entity.Base.EntityMeter it in bc.GetListQuery(MeterLOCNo1, MeterLOCNo2, MeterLOCNo3, MeterLOCNo4, MeterNo, MeterType, MeterUsageType, MeterRMID, "", MeterSize, MeterStatus, page, pageSize))
            {
                sb.Append("<tr class=\"text-c\" id=\"" + it.MeterNo + "\">");
                sb.Append("<td class=\"printck\"><input type=\"checkbox\" class=\"input-text size-MINI\" value=\"" + it.MeterNo + "\" name=\"meterno\" />");
                sb.Append("<td>" + r.ToString() + "</td>");
                sb.Append("<td>" + it.MeterRMID + "</td>");
                sb.Append("<td>" + it.MeterNo + "</td>");
                sb.Append("<td>" + it.MeterName + "</td>");
                sb.Append("<td>" + it.MeterLOCNo1Name + "/" + it.MeterLOCNo2Name + "/" + it.MeterLOCNo3Name + "/" + it.MeterLOCNo4Name + "</td>");
                sb.Append("<td>" + it.MeterRate.ToString("0.####") + "</td>");
                sb.Append("<td>" + it.MeterDigit + "</td>");
                sb.Append("<td>" + it.MeterUsageTypeName + "</td>");
                sb.Append("<td>" + it.MeterReadout.ToString("0.####") + "</td>");
                sb.Append("<td>" + ParseStringForDate(it.MeterReadoutDate) + "</td>");
                sb.Append("<td class=\"td-status\"><span class=\"label " + (it.MeterStatus == "open" ? "label-success" : "") + " radius\">" + it.MeterStatusName + "</span></td>");
                sb.Append("</tr>");
                r++;
            }
            sb.Append("</tbody>");
            sb.Append("</table>");

            sb.Append(Paginat(bc.GetListCount(MeterLOCNo1, MeterLOCNo2, MeterLOCNo3, MeterLOCNo4, MeterNo, MeterType, MeterUsageType, MeterRMID, "", MeterSize, MeterStatus), pageSize, page, 7));

            return(sb.ToString());
        }
示例#3
0
        private string validaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessMeter bc = new project.Business.Base.BusinessMeter();
                bc.load(jp.getValue("id"));
                if (bc.Entity.MeterStatus == "open")
                {
                    bc.Entity.MeterStatus = "close";
                }
                else
                {
                    bc.Entity.MeterStatus = "open";
                }

                int r = bc.valid();
                if (r <= 0)
                {
                    flag = "2";
                }

                if (bc.Entity.MeterStatus == "close")
                {
                    collection.Add(new JsonStringValue("stat", "<span class=\"label radius\">禁用</span>"));
                }
                else
                {
                    collection.Add(new JsonStringValue("stat", "<span class=\"label label-success radius\">正常</span>"));
                }

                collection.Add(new JsonStringValue("id", jp.getValue("id")));
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("type", "valid"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList(jp.getValue("MeterLOCNo1S"), jp.getValue("MeterLOCNo2S"), jp.getValue("MeterLOCNo3S"),
                                                                     jp.getValue("MeterLOCNo4S"), jp.getValue("MeterNoS"), jp.getValue("MeterTypeS"), jp.getValue("MeterUsageTypeS"),
                                                                     jp.getValue("MeterRMIDS"), jp.getValue("MeterSizeS"), jp.getValue("MeterStatusS"), ParseIntForString(jp.getValue("page")))));
            return(collection.ToString());
        }
示例#4
0
        private string deleteaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessMeter bc = new project.Business.Base.BusinessMeter();
                bc.load(jp.getValue("id"));

                if (obj.PopulateDataSet("select 1 from Op_ChangeMeter where OldMeterNo='" + bc.Entity.MeterNo + "' or NewMeterNo='" + bc.Entity.MeterNo + "'").Tables[0].Rows.Count > 0)
                {
                    flag = "3";
                }
                else
                {
                    if (obj.PopulateDataSet("select 1 from Op_Readout where MeterNo='" + bc.Entity.MeterNo + "'").Tables[0].Rows.Count > 0)
                    {
                        flag = "3";
                    }
                    else
                    {
                        int r = bc.delete();
                        if (r <= 0)
                        {
                            flag = "2";
                        }
                    }
                }
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("type", "delete"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList(jp.getValue("MeterLOCNo1S"), jp.getValue("MeterLOCNo2S"), jp.getValue("MeterLOCNo3S"),
                                                                     jp.getValue("MeterLOCNo4S"), jp.getValue("MeterNoS"), jp.getValue("MeterTypeS"), jp.getValue("MeterUsageTypeS"),
                                                                     jp.getValue("MeterRMIDS"), jp.getValue("MeterSizeS"), jp.getValue("MeterStatusS"), ParseIntForString(jp.getValue("page")))));

            return(collection.ToString());
        }
示例#5
0
    public bool AddMeterReadout(string key, string userName, string meterReadoutObj, byte[] readoutImg)
    {
        string imgName = string.Empty;

        if (key != "6E5F0C851FD4")
        {
            return(false);
        }
        try
        {
            var entityReadout = JsonConvert.DeserializeObject <project.Entity.Op.EntityReadout>(meterReadoutObj);
            entityReadout.RowPointer = Guid.NewGuid().ToString();
            //表记资料
            var businessMeter = new project.Business.Base.BusinessMeter();
            businessMeter.load(entityReadout.MeterNo);
            if (businessMeter.Entity == null)
            {
                return(false);
            }
            entityReadout.RMID      = businessMeter.Entity.MeterRMID;
            entityReadout.MeterType = businessMeter.Entity.MeterType;
            entityReadout.MeteRate  = businessMeter.Entity.MeterRate;
            //抄表附带数据
            DataTable dt = obj.PopulateDataSet(string.Format("SELECT READERNO FROM Mstr_MeterReader WHERE READERNAME='{0}'", userName)).Tables[0];
            entityReadout.ROOperator   = dt.Rows.Count > 0 ? dt.Rows[0]["ReaderNo"].ToString() : "";
            entityReadout.ROCreateDate = GetDate();
            entityReadout.ROCreator    = userName;
            entityReadout.RODate       = GetDate();
            //图片处理
            if (readoutImg != null)
            {
                imgName = SaveReadoutImg(entityReadout.MeterNo, readoutImg);
            }
            entityReadout.Img = imgName;
            //数据保存
            var businessReadout = new project.Business.Op.BusinessReadout(entityReadout);
            if (businessReadout.Save("insert") > 0)
            {
                return(true);
            }
            else
            {
                if (!string.IsNullOrEmpty(imgName))
                {
                    string imgPath = ReadoutImgPath + imgName;
                    if (File.Exists(imgPath))
                    {
                        File.Delete(imgPath);
                    }
                }
            }
        }
        catch (Exception)
        {
            if (!string.IsNullOrEmpty(imgName))
            {
                string imgPath = ReadoutImgPath + imgName;
                if (File.Exists(imgPath))
                {
                    File.Delete(imgPath);
                }
            }
        }
        return(false);
    }
示例#6
0
    public string MeterReadout(string MeterNo, string ReadoutType, decimal LastReadout, decimal Readout,
                               decimal JoinReadings, decimal Readings, string UserName, string KEY, byte[] ImgByte)
    {
        if (KEY != "6E5F0C851FD4")
        {
            return("");
        }

        string InfoMsg = "";
        string imgName = MeterNo + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
        string imgPath = ReadoutImgPath + imgName;

        try
        {
            if (ImgByte != null)
            {
                SaveReadoutImg(MeterNo, imgName, ImgByte);                 //保存图片
            }
            else
            {
                imgName = string.Empty;
            }

            project.Business.Op.BusinessReadout bc = new project.Business.Op.BusinessReadout();
            string id = Guid.NewGuid().ToString();
            bc.Entity.RowPointer = id;
            bc.Entity.MeterNo    = MeterNo;

            string isOk = "1";
            try
            {
                project.Business.Base.BusinessMeter bm = new project.Business.Base.BusinessMeter();
                bm.load(MeterNo);
                bc.Entity.RMID      = bm.Entity.MeterRMID;
                bc.Entity.MeterType = bm.Entity.MeterType;
                bc.Entity.MeteRate  = bm.Entity.MeterRate;
            }
            catch
            {
                isOk    = "0";
                InfoMsg = "当前表记未找到!";
                DelReadoutImg(imgPath);
            }

            if (isOk == "1")
            {
                bc.Entity.ReadoutType  = ReadoutType;
                bc.Entity.LastReadout  = LastReadout;
                bc.Entity.Readout      = Readout;
                bc.Entity.JoinReadings = JoinReadings;
                bc.Entity.Readings     = Readings;
                DataTable tempDt = obj.PopulateDataSet(string.Format("SELECT READERNO FROM Mstr_MeterReader WHERE READERNAME='{0}'", UserName)).Tables[0];
                bc.Entity.ROOperator   = tempDt.Rows.Count > 0 ? tempDt.Rows[0]["ReaderNo"].ToString() : "";
                bc.Entity.RODate       = GetDate();
                bc.Entity.Img          = imgName;
                bc.Entity.ROCreateDate = GetDate();
                bc.Entity.ROCreator    = UserName;

                //获取换表记录 [换表记录已审核,并没有被抄表引用]
                DataTable dt = obj.PopulateDataSet("select RowPointer,OldMeterReadings from Op_ChangeMeter " +
                                                   "where AuditStatus='1' and NewMeterNo='" + bc.Entity.MeterNo + "' " +
                                                   "and RowPointer not in (select ChangeID from Op_Readout_ChangeList)").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    bc.Entity.IsChange = true;
                    decimal OldMeterReadings = 0;

                    //考虑多次换表的情况
                    foreach (DataRow dr in dt.Rows)
                    {
                        OldMeterReadings += ParseDecimalForString(dr["OldMeterReadings"].ToString());
                    }
                    bc.Entity.OldMeterReadings = OldMeterReadings;
                }
                else
                {
                    bc.Entity.IsChange         = false;
                    bc.Entity.OldMeterReadings = 0;
                }

                int r = bc.Save("insert");
                if (r <= 0)
                {
                    DelReadoutImg(imgPath);
                    InfoMsg = "抄表写入失败!";
                }
                else
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        obj.ExecuteNonQuery("insert into Op_Readout_ChangeList(RowPointer,RefRP,ChangeID) values(newid(),'" + id + "','" + dr["RowPointer"].ToString() + "')");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            DelReadoutImg(imgPath);
            InfoMsg = ex.Message;
        }

        return(InfoMsg);
    }
示例#7
0
        private string submitaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessMeter bc = new project.Business.Base.BusinessMeter();
                if (jp.getValue("tp") == "update")
                {
                    bc.load(jp.getValue("id"));
                    bc.Entity.MeterName       = jp.getValue("MeterName");
                    bc.Entity.MeterType       = jp.getValue("MeterType");
                    bc.Entity.MeterLOCNo1     = jp.getValue("MeterLOCNo1");
                    bc.Entity.MeterLOCNo2     = jp.getValue("MeterLOCNo2");
                    bc.Entity.MeterLOCNo3     = jp.getValue("MeterLOCNo3");
                    bc.Entity.MeterLOCNo4     = jp.getValue("MeterLOCNo4");
                    bc.Entity.MeterRate       = ParseDecimalForString(jp.getValue("MeterRate"));
                    bc.Entity.MeterDigit      = ParseIntForString(jp.getValue("MeterDigit"));
                    bc.Entity.MeterUsageType  = jp.getValue("MeterUsageType");
                    bc.Entity.MeterNatureType = jp.getValue("MeterNatureType");
                    //bc.Entity.MeterReadout = ParseDecimalForString(jp.getValue("MeterReadout"));
                    //bc.Entity.MeterReadoutDate = ParseDateForString(jp.getValue("MeterReadoutDate"));
                    bc.Entity.MeterRMID           = jp.getValue("MeterRMID");
                    bc.Entity.MeterSize           = jp.getValue("MeterSize");
                    bc.Entity.MeterRelatedMeterNo = jp.getValue("MeterRelatedMeterNo");
                    bc.Entity.Addr = jp.getValue("Addr");

                    int r = bc.Save("update");

                    if (r <= 0)
                    {
                        flag = "2";
                    }
                }
                else
                {
                    Data      obj = new Data();
                    DataTable dt  = obj.PopulateDataSet("select cnt=COUNT(*) from Mstr_Meter where MeterNo='" + jp.getValue("MeterNo") + "'").Tables[0];
                    if (int.Parse(dt.Rows[0]["cnt"].ToString()) > 0)
                    {
                        flag = "3";
                    }
                    else
                    {
                        bc.Entity.MeterNo         = jp.getValue("MeterNo");
                        bc.Entity.MeterName       = jp.getValue("MeterName");
                        bc.Entity.MeterType       = jp.getValue("MeterType");
                        bc.Entity.MeterLOCNo1     = jp.getValue("MeterLOCNo1");
                        bc.Entity.MeterLOCNo2     = jp.getValue("MeterLOCNo2");
                        bc.Entity.MeterLOCNo3     = jp.getValue("MeterLOCNo3");
                        bc.Entity.MeterLOCNo4     = jp.getValue("MeterLOCNo4");
                        bc.Entity.MeterRate       = ParseDecimalForString(jp.getValue("MeterRate"));
                        bc.Entity.MeterDigit      = ParseIntForString(jp.getValue("MeterDigit"));
                        bc.Entity.MeterUsageType  = jp.getValue("MeterUsageType");
                        bc.Entity.MeterNatureType = jp.getValue("MeterNatureType");
                        //bc.Entity.MeterReadout = ParseDecimalForString(jp.getValue("MeterReadout"));
                        //bc.Entity.MeterReadoutDate = ParseDateForString(jp.getValue("MeterReadoutDate"));
                        bc.Entity.MeterRMID           = jp.getValue("MeterRMID");
                        bc.Entity.MeterSize           = jp.getValue("MeterSize");
                        bc.Entity.MeterRelatedMeterNo = jp.getValue("MeterRelatedMeterNo");
                        bc.Entity.Addr = jp.getValue("Addr");

                        bc.Entity.MeterCreator    = user.Entity.UserName;
                        bc.Entity.MeterCreateDate = GetDate();

                        int r = bc.Save("insert");
                        if (r <= 0)
                        {
                            flag = "2";
                        }
                    }
                }
            }
            catch { flag = "2"; }


            collection.Add(new JsonStringValue("type", "submit"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList(jp.getValue("MeterLOCNo1S"), jp.getValue("MeterLOCNo2S"), jp.getValue("MeterLOCNo3S"),
                                                                     jp.getValue("MeterLOCNo4S"), jp.getValue("MeterNoS"), jp.getValue("MeterTypeS"), jp.getValue("MeterUsageTypeS"),
                                                                     jp.getValue("MeterRMIDS"), jp.getValue("MeterSizeS"), jp.getValue("MeterStatusS"), ParseIntForString(jp.getValue("page")))));

            return(collection.ToString());
        }
示例#8
0
        private string updateaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag = "1";

            try
            {
                Business.Base.BusinessMeter bc = new project.Business.Base.BusinessMeter();
                bc.load(jp.getValue("id"));

                collection.Add(new JsonStringValue("MeterNo", bc.Entity.MeterNo));
                collection.Add(new JsonStringValue("MeterName", bc.Entity.MeterName));
                collection.Add(new JsonStringValue("MeterType", bc.Entity.MeterType));
                collection.Add(new JsonStringValue("MeterLOCNo1", bc.Entity.MeterLOCNo1));
                collection.Add(new JsonStringValue("MeterLOCNo2", bc.Entity.MeterLOCNo2));
                collection.Add(new JsonStringValue("MeterLOCNo3", bc.Entity.MeterLOCNo3));
                collection.Add(new JsonStringValue("MeterLOCNo4", bc.Entity.MeterLOCNo4));
                collection.Add(new JsonStringValue("MeterRate", bc.Entity.MeterRate.ToString("0.####")));
                collection.Add(new JsonStringValue("MeterDigit", bc.Entity.MeterDigit.ToString()));
                collection.Add(new JsonStringValue("MeterUsageType", bc.Entity.MeterUsageType));
                collection.Add(new JsonStringValue("MeterNatureType", bc.Entity.MeterNatureType));
                collection.Add(new JsonStringValue("MeterReadout", bc.Entity.MeterReadout.ToString("0.####")));
                collection.Add(new JsonStringValue("MeterReadoutDate", ParseStringForDate(bc.Entity.MeterReadoutDate)));
                collection.Add(new JsonStringValue("MeterRMID", bc.Entity.MeterRMID));
                collection.Add(new JsonStringValue("MeterSize", bc.Entity.MeterSize));
                collection.Add(new JsonStringValue("MeterRelatedMeterNo", bc.Entity.MeterRelatedMeterNo));
                collection.Add(new JsonStringValue("Addr", bc.Entity.Addr));

                string subtype = "";
                int    row     = 0;
                Business.Base.BusinessLocation bt = new Business.Base.BusinessLocation();
                foreach (Entity.Base.EntityLocation it in bt.GetListQuery(string.Empty, string.Empty, bc.Entity.MeterLOCNo1))
                {
                    subtype += it.LOCNo + ":" + it.LOCName + ";";
                    row++;
                }
                collection.Add(new JsonNumericValue("row", row));
                collection.Add(new JsonStringValue("subtype", subtype));

                row     = 0;
                subtype = "";
                foreach (Entity.Base.EntityLocation it in bt.GetListQuery(string.Empty, string.Empty, bc.Entity.MeterLOCNo2))
                {
                    subtype += it.LOCNo + ":" + it.LOCName + ";";
                    row++;
                }
                collection.Add(new JsonNumericValue("row1", row));
                collection.Add(new JsonStringValue("subtype1", subtype));

                row     = 0;
                subtype = "";
                foreach (Entity.Base.EntityLocation it in bt.GetListQuery(string.Empty, string.Empty, bc.Entity.MeterLOCNo3))
                {
                    subtype += it.LOCNo + ":" + it.LOCName + ";";
                    row++;
                }
                collection.Add(new JsonNumericValue("row2", row));
                collection.Add(new JsonStringValue("subtype2", subtype));
            }
            catch
            { flag = "2"; }

            collection.Add(new JsonStringValue("type", "update"));
            collection.Add(new JsonStringValue("flag", flag));

            return(collection.ToString());
        }