Example #1
0
        //
        public HttpResponseMessage ItemSave(eqia_rdsavedata itemvalue)
        {
            string result = string.Empty;

            try
            {
                if (itemvalue.fldUserID == null || itemvalue.fldUserName == null)
                {
                    itemvalue.fldUserID   = rule.ConductUserinfo(itemvalue.fldUserID);
                    itemvalue.fldUserName = "";
                }
                if (itemvalue.BeginDate != null && itemvalue.EndDate != null)
                {
                    if (itemvalue.fldSTCode != null)
                    {
                        if (itemvalue.fldPCode != null)
                        {
                            if (itemvalue.fldItemData.Count > 0)
                            {
                                List <tblEQIA_RDPI_Basedata_Pre> lstData = new List <tblEQIA_RDPI_Basedata_Pre>();
                                tblEQIA_RDPI_Basedata_Pre        objData = new tblEQIA_RDPI_Basedata_Pre();
                                tblEQI_InputDate inputdate_new           = new tblEQI_InputDate();
                                objData.fldSTCode = itemvalue.fldSTCode;
                                objData.fldPCode  = itemvalue.fldPCode;

                                objData.fldSYear   = inputdate_new.fldSYear = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Year.ToString());
                                objData.fldSMonth  = inputdate_new.fldSMonth = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Month.ToString());
                                objData.fldSDay    = inputdate_new.fldSDay = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Day.ToString());
                                objData.fldSHour   = inputdate_new.fldSHour = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Hour.ToString());
                                objData.fldSMinute = inputdate_new.fldSMinute = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Minute.ToString());
                                objData.fldEYear   = inputdate_new.fldEYear = decimal.Parse(Convert.ToDateTime(itemvalue.EndDate).Year.ToString());
                                objData.fldEMonth  = inputdate_new.fldEMonth = decimal.Parse(Convert.ToDateTime(itemvalue.EndDate).Month.ToString());
                                objData.fldEDay    = inputdate_new.fldEDay = decimal.Parse(Convert.ToDateTime(itemvalue.EndDate).Day.ToString());
                                objData.fldEHour   = inputdate_new.fldEHour = decimal.Parse(Convert.ToDateTime(itemvalue.EndDate).Hour.ToString());
                                objData.fldEMinute = inputdate_new.fldEMinute = decimal.Parse(Convert.ToDateTime(itemvalue.EndDate).Minute.ToString());

                                objData.fldUserID         = inputdate_new.fldUserID = int.Parse(itemvalue.fldUserID);
                                objData.fldFlag           = 0;
                                objData.fldCityID_Operate = inputdate_new.fldCityID = int.Parse(itemvalue.fldCityID_Operate);
                                objData.fldCityID_Submit  = itemvalue.fldCityID_Submit;
                                objData.fldDate_Operate   = DateTime.Now;
                                inputdate_new.fldObject   = "eqia_rd";

                                Regex regexvalue2 = new Regex(@"^(\d*\.?\d+)?[lL]$");
                                for (int i = 0; i < itemvalue.fldItemData.Count; i++)
                                {
                                    decimal            dValue    = -1;
                                    RuletblEQIA_R_Item rule_item = new RuletblEQIA_R_Item();

                                    DataTable dataTable = rule_item.GetItemAndSTDDataByItemCode(itemvalue.fldItemData[i].itemcode);

                                    if (dataTable.Rows.Count > 0)
                                    {
                                        if (itemvalue.fldItemData[i].itemvalue.Trim() != "")
                                        {
                                            if (regexvalue2.IsMatch(itemvalue.fldItemData[i].itemvalue.ToString().Trim()))
                                            {
                                                if (itemvalue.fldItemData[i].itemvalue.ToString().Trim().ToLower() == "l")
                                                {
                                                    decimal temp = Convert.ToDecimal(dataTable.Rows[0]["fldSense"].ToString());

                                                    if (temp <= 0)
                                                    {
                                                        result = rule.JsonStr("error", "项目[" + dataTable.Rows[0]["fldItemName"].ToString() + "]的检出限<=0,不能输入 L 作为监测值", "");
                                                        return(new HttpResponseMessage {
                                                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                                                        });
                                                    }
                                                    dValue = -temp;
                                                }
                                                else
                                                {
                                                    dValue = -Convert.ToDecimal(itemvalue.fldItemData[i].itemvalue.ToString().Trim().Replace("l", "").Replace("L", ""));
                                                }
                                                if (dValue == -1)
                                                {
                                                    dValue = Convert.ToDecimal(-0.99999999);
                                                }
                                            }
                                            else
                                            {
                                                dValue = Convert.ToDecimal(itemvalue.fldItemData[i].itemvalue.ToString().Trim());
                                            }
                                        }
                                    }
                                    tblEQIA_RDPI_Basedata_Pre objTmp = objData.Clone();
                                    objTmp.fldItemCode       = itemvalue.fldItemData[i].itemcode.ToString();
                                    objTmp.fldItemValue      = dValue;
                                    objTmp.fldCityID_Operate = Int32.Parse(itemvalue.fldCityID_Operate);
                                    objTmp.fldCityID_Submit  = itemvalue.fldCityID_Submit;
                                    lstData.Add(objTmp);
                                }
                                RuletblEQIA_RDPI_Basedata_Pre rule_basedata = new RuletblEQIA_RDPI_Basedata_Pre();
                                bool issave = rule_basedata.InsertAll(lstData, inputdate_new);
                                if (issave)
                                {
                                    RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                                    rule_wol.WriteLog(0, "录入降尘数据到临时表,测点代码:" + itemvalue.fldPCode +
                                                      ";时间:" + itemvalue.BeginDate + " " + itemvalue.EndDate + ";录入者ID:" + int.Parse(itemvalue.fldUserID), itemvalue.fldUserName, int.Parse(itemvalue.fldUserID), int.Parse(itemvalue.fldCityID_Submit));
                                    result = rule.JsonStr("error", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                                }
                                else
                                {
                                    result = rule.JsonStr("error", "数据保存失败,请重试", "");
                                }
                            }
                            else
                            {
                                result = rule.JsonStr("error", "缺少因子监测值", "");
                            }
                        }
                        else
                        {
                            result = rule.JsonStr("error", "缺少点位代码", "");
                        }
                    }
                    else
                    {
                        result = rule.JsonStr("error", "缺少城市代码", "");
                    }
                }
                else
                {
                    result = rule.JsonStr("error", "缺少监测时间", "");
                }
            }
            catch (InputException ex)
            {
                result = rule.JsonStr("error", "数据保存失败," + ex.Message, "");
            }
            catch (InsertException ex)
            {
                PageException pagex = new PageException(int.Parse(itemvalue.fldUserID), ex.Message,
                                                        "Eqia_rdPointInputController", "ItemSave", "");
                result = rule.JsonStr("error", "数据写入数据库失败," + ex.Message, "");
            }
            catch (Exception ex)
            {
                PageException pagex = new PageException(int.Parse(itemvalue.fldUserID), ex.Message,
                                                        "Eqia_rdPointInputController", "ItemSave", "");
                result = rule.JsonStr("error", "数据保存时出现了错误," + ex.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Example #2
0
        //
        public HttpResponseMessage ItemSave(eqia_rsavedata itemvalue)
        {
            string result = string.Empty;

            if (itemvalue.fldUserID == null || itemvalue.fldUserName == null)
            {
                itemvalue.fldUserID   = rule.ConductUserinfo(itemvalue.fldUserID);
                itemvalue.fldUserName = "";
            }
            try
            {
                if (itemvalue.BeginDate != null && itemvalue.EndDate != null)
                {
                    if (itemvalue.fldSTCode != null)
                    {
                        if (itemvalue.fldRCode != null)
                        {
                            if (itemvalue.fldRSCode != null)
                            {
                                if (itemvalue.fldItemData.Count > 0)
                                {
                                    List <tblEQIW_R_Basedata_Pre> lstData  = new List <tblEQIW_R_Basedata_Pre>();
                                    tblEQIW_R_Basedata_Pre        objData  = new tblEQIW_R_Basedata_Pre();
                                    List <tblEQIW_D_Basedata_Pre> lstDataD = new List <tblEQIW_D_Basedata_Pre>();
                                    tblEQI_InputDate inputdate_new         = new tblEQI_InputDate();
                                    objData.fldSTCode         = itemvalue.fldSTCode;
                                    objData.fldRCode          = itemvalue.fldRCode;
                                    objData.fldRSCode         = itemvalue.fldRSCode;
                                    objData.fldRSC            = itemvalue.fldRSC;
                                    objData.fldSAMPH          = "1";
                                    objData.fldSAMPR          = "1";
                                    objData.fldYear           = inputdate_new.fldSYear = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Year.ToString());
                                    objData.fldMonth          = inputdate_new.fldSMonth = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Month.ToString());
                                    objData.fldDay            = inputdate_new.fldSDay = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Day.ToString());
                                    objData.fldHour           = inputdate_new.fldSHour = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Hour.ToString());
                                    objData.fldMinute         = inputdate_new.fldSMinute = decimal.Parse(Convert.ToDateTime(itemvalue.BeginDate).Minute.ToString());
                                    objData.fldSource         = 0;
                                    objData.fldUserID         = inputdate_new.fldUserID = int.Parse(itemvalue.fldUserID);
                                    objData.fldFlag           = 0;
                                    objData.fldCityID_Operate = inputdate_new.fldCityID = int.Parse(itemvalue.fldCityID_Operate);
                                    objData.fldCityID_Submit  = itemvalue.fldCityID_Submit;
                                    objData.fldDate_Operate   = DateTime.Now;
                                    objData.fldBatch          = itemvalue.BeginDate + Guid.NewGuid().ToString();
                                    inputdate_new.fldObject   = "eqiw_r";
                                    Regex regexvalue  = new Regex(@"^(\d*\.?\d+)+$");
                                    Regex regexvalue2 = new Regex(@"^(\d*\.?\d+)?[lL]$");
                                    for (int i = 0; i < itemvalue.fldItemData.Count; i++)
                                    {
                                        decimal dValue = -1;


                                        DataTable dataTable = rule.GetItem("地表水", itemvalue.fldItemData[i].itemcode);

                                        if (dataTable.Rows.Count > 0)
                                        {
                                            if (itemvalue.fldItemData[i].itemvalue.Trim() != "")
                                            {
                                                //if (!regexvalue.IsMatch(itemvalue.fldItemData[i].itemvalue) && !regexvalue2.IsMatch(itemvalue.fldItemData[i].itemvalue))
                                                //{
                                                //    result = rule.JsonStr("error", "项目[" + dataTable.Rows[0]["fldItemName"].ToString() + "]的监测值只能输入数字或字符L和l!", "");
                                                //    return new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") };
                                                //}
                                                if (!regexvalue2.IsMatch(itemvalue.fldItemData[i].itemvalue))
                                                {
                                                    dValue = Convert.ToDecimal(itemvalue.fldItemData[i].itemvalue);
                                                    decimal dMinValue = Convert.ToDecimal(dataTable.Rows[0]["fldMinValue"].ToString());
                                                    if (dMinValue >= 0 && dValue < dMinValue)
                                                    {
                                                        result = rule.JsonStr("error", "" + dataTable.Rows[0]["fldItemName"] + "的监测值应 >=" + dMinValue, "");
                                                        return(new HttpResponseMessage {
                                                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                                                        });
                                                    }
                                                    decimal dMaxValue = Convert.ToDecimal(dataTable.Rows[0]["fldMaxValue"].ToString());
                                                    if (dMaxValue > 0 && dValue > dMaxValue)
                                                    {
                                                        result = rule.JsonStr("error", "" + dataTable.Rows[0]["fldItemName"] + "的监测值应 <=" + dMaxValue, "");
                                                        return(new HttpResponseMessage {
                                                            Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                                                        });
                                                    }
                                                }
                                                if (regexvalue2.IsMatch(itemvalue.fldItemData[i].itemvalue.Trim()))
                                                {
                                                    if (itemvalue.fldItemData[i].itemvalue.Trim().ToLower() == "l")
                                                    {
                                                        decimal temp = Convert.ToDecimal(dataTable.Rows[0]["fldSense"].ToString());

                                                        if (temp <= 0)
                                                        {
                                                            result = rule.JsonStr("error", "项目[" + dataTable.Rows[0]["fldItemName"].ToString() + "]的检出限<=0,不能输入 L 作为监测值", "");
                                                            return(new HttpResponseMessage {
                                                                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                                                            });
                                                        }
                                                        dValue = -temp;
                                                    }
                                                    else
                                                    {
                                                        dValue = -Convert.ToDecimal(itemvalue.fldItemData[i].itemvalue.Trim().Replace("l", "").Replace("L", ""));
                                                    }
                                                    if (dValue == -1)
                                                    {
                                                        dValue = Convert.ToDecimal(-0.99999999);
                                                    }
                                                }
                                                else
                                                {
                                                    dValue = Convert.ToDecimal(itemvalue.fldItemData[i].itemvalue.ToString().Trim());
                                                }
                                            }

                                            tblEQIW_R_Basedata_Pre objTmp = objData.Clone();
                                            objTmp.fldItemCode       = itemvalue.fldItemData[i].itemcode;
                                            objTmp.fldItemValue      = dValue;
                                            objTmp.fldCityID_Operate = Int32.Parse(itemvalue.fldCityID_Operate);
                                            objTmp.fldCityID_Submit  = itemvalue.fldCityID_Submit;
                                            lstData.Add(objTmp);
                                        }
                                    }
                                    RuletblEQIW_R_Basedata_Pre rule_basedata = new RuletblEQIW_R_Basedata_Pre();
                                    bool issave = rule_basedata.InsertAll(lstData, inputdate_new);
                                    if (issave)
                                    {
                                        RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                                        rule_wol.WriteLog(0, "录入河流数据到临时表,断面" + itemvalue.fldRSCode +
                                                          ";时间:" + itemvalue.BeginDate + " " + itemvalue.EndDate + ";录入者ID:" + int.Parse(itemvalue.fldUserID), itemvalue.fldUserName, int.Parse(itemvalue.fldUserID), int.Parse(itemvalue.fldCityID_Submit));
                                        result = rule.JsonStr("error", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                                    }
                                    else
                                    {
                                        result = rule.JsonStr("error", "数据保存失败,请重试", "");
                                    }
                                }
                                else
                                {
                                    result = rule.JsonStr("error", "缺少因子监测值", "");
                                }
                            }
                            else
                            {
                                result = rule.JsonStr("error", "缺少断面代码", "");
                            }
                        }
                        else
                        {
                            result = rule.JsonStr("error", "缺少河流代码", "");
                        }
                    }
                    else
                    {
                        result = rule.JsonStr("error", "缺少城市代码", "");
                    }
                }
                else
                {
                    result = rule.JsonStr("error", "缺少监测时间", "");
                }
            }
            catch (InputException ex)
            {
                result = rule.JsonStr("error", "数据保存失败," + ex.Message, "");
            }
            catch (InsertException ex)
            {
                PageException pagex = new PageException(int.Parse(itemvalue.fldUserID), ex.Message,
                                                        "Eqiw_rPointInputController", "ItemSave", "");
                result = rule.JsonStr("error", "数据写入数据库失败," + ex.Message, "");
            }
            catch (Exception ex)
            {
                PageException pagex = new PageException(int.Parse(itemvalue.fldUserID), ex.Message,
                                                        "Eqiw_rPointInputController", "ItemSave", "");
                result = rule.JsonStr("error", "数据保存时出现了错误," + ex.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        /// <summary>
        /// 功能描述:数据插入到临时表
        /// 创建  人:周文卿
        /// 创建时间:2017/07/11
        /// 修改原因:
        /// 修改时间:
        /// 修改  人:
        /// </summary>
        /// <param name="inputdata">插入的实体类</param>
        /// <returns>json(是否成功)</returns>
        public HttpResponseMessage ItemSave(List <tbleqia_r_table> inputdata)
        {
            string returntext = "";

            try
            {
                Regex regexvalue  = new Regex(@"^(\d*\.?\d+)+$");
                Regex regexvalue2 = new Regex(@"^(\d*\.?\d+)?[lL]$");
                List <tblEQIA_RPI_Basedata_Pre> lstData = new List <tblEQIA_RPI_Basedata_Pre>();
                tblEQIA_RPI_Basedata_Pre        objData = new tblEQIA_RPI_Basedata_Pre();//临时表

                for (int i = 0; i < inputdata.Count; i++)
                {
                    List <tbaeqia_r_value> valueall = inputdata[i].valueall;
                    for (int j = 0; j < valueall.Count; j++)
                    {
                        objData.fldSTCode         = valueall[j].fldSTCode;
                        objData.fldUserID         = int.Parse(inputdata[i].fldUserID);
                        objData.fldFlag           = 0;
                        objData.fldCityID_Operate = int.Parse(inputdata[i].fldCityID_Operate);
                        objData.fldCityID_Submit  = inputdata[i].fldCityID_Submit;
                        objData.fldDate_Operate   = DateTime.Now;
                        RuletblEQIA_R_Item rule_item = new RuletblEQIA_R_Item();
                        DataTable          dataTable = rule_item.GetItemAndSTDDataByItemCode(inputdata[i].itemcode);
                        decimal            dValue    = -1;
                        if (dataTable.Rows.Count > 0)
                        {
                            if (valueall[j].monitorvalue != "")
                            {
                                if (regexvalue2.IsMatch(valueall[j].monitorvalue))
                                {
                                    if (valueall[j].monitorvalue.ToString().Trim().ToLower() == "l")
                                    {
                                        decimal temp = Convert.ToDecimal(dataTable.Rows[0]["fldSense"].ToString());
                                        if (temp <= 0)
                                        {
                                            returntext = rule.JsonStr("error", "项目[" + dataTable.Rows[0]["fldItemName"].ToString() + "]的检出限<=0,不能输入 L 作为监测值", "");
                                            return(new HttpResponseMessage {
                                                Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json")
                                            });
                                        }
                                        dValue = -temp;
                                    }
                                    else
                                    {
                                        dValue = -Convert.ToDecimal(valueall[j].monitorvalue.ToString().Trim().Replace("l", "").Replace("L", ""));
                                    }
                                    if (dValue == -1)
                                    {
                                        dValue = Convert.ToDecimal(-0.99999999);
                                    }
                                }
                                else
                                {
                                    dValue = Convert.ToDecimal(valueall[j].monitorvalue.ToString().Trim());
                                }
                            }
                        }
                        tblEQIA_RPI_Basedata_Pre objTmp = objData.Clone();
                        objTmp.fldPCode = valueall[j].fldPCode;
                        DateTime time = DateTime.Parse(valueall[j].fldDate.ToString());
                        objTmp.fldSYear     = time.Year;
                        objTmp.fldSMonth    = time.Month;
                        objTmp.fldSDay      = time.Day;
                        objTmp.fldSHour     = 0;
                        objTmp.fldSMinute   = 0;
                        objTmp.fldEYear     = time.Year;
                        objTmp.fldEMonth    = time.Month;
                        objTmp.fldEDay      = time.Day;
                        objTmp.fldEHour     = 0;
                        objTmp.fldEMinute   = 0;
                        objTmp.fldFlag      = 0;
                        objTmp.fldImport    = false;
                        objTmp.fldItemCode  = inputdata[i].itemcode;
                        objTmp.fldItemValue = dValue;
                        lstData.Add(objTmp);
                    }
                }
                RuletblEQIA_RPI_Basedata_Pre rule_basedata = new RuletblEQIA_RPI_Basedata_Pre();
                bool issave = rule_basedata.InsertAll(lstData);
                if (issave)
                {
                    RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                    rule_wol.WriteLog(0, "录入大气数据到临时表", "", int.Parse(inputdata[0].fldUserID), int.Parse(inputdata[0].fldCityID_Operate));
                    returntext = rule.JsonStr("ok", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                }
                else
                {
                    returntext = rule.JsonStr("error", "保存失败!请重试!", "");
                }
            }
            catch (InputException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (InsertException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (Exception ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json")
            });
        }
        /// <summary>
        /// 功能描述:数据插入到临时表
        /// 创建  人:周文卿
        /// 创建时间:2017/07/12
        /// </summary>
        /// <param name="inputdata">插入的实体类</param>
        /// <returns>json(是否成功)</returns>
        public HttpResponseMessage ItemSave(List<tbleqiw_r_table> inputdata)
        {
            string returntext = "";

            try
            {
                Regex regexvalue = new Regex(@"^(\d*\.?\d+)+$");
                Regex regexvalue2 = new Regex(@"^(\d*\.?\d+)?[lL]$");

                //赋值点位时间信息
                List<tblEQIW_R_Basedata_Pre> lstData = new List<tblEQIW_R_Basedata_Pre>();
                tblEQIW_R_Basedata_Pre objData = new tblEQIW_R_Basedata_Pre();
                List<tblEQIW_D_Basedata_Pre> lstDataD = new List<tblEQIW_D_Basedata_Pre>();
                for (int i = 0; i < inputdata.Count; i++)
                {
                    List<tbaeqiw_r_value> valueall = inputdata[i].valueall;
                    for (int j = 0; j < valueall.Count; j++)
                    {
                        objData.fldSTCode = valueall[j].fldSTCode;
                        objData.fldRSC = inputdata[i].fldRSC;
                        objData.fldUserID = int.Parse(inputdata[i].fldUserID);
                        objData.fldFlag = 0;
                        objData.fldCityID_Operate = int.Parse(inputdata[i].fldCityID_Operate);
                        objData.fldCityID_Submit = inputdata[i].fldCityID_Submit;
                        objData.fldDate_Operate = DateTime.Now;
                        decimal dValue = -1;
                        string samphvalue = valueall[j].monitorvalue;
                        #region 修改监测值
                        if (samphvalue != "")
                        {
                            if (regexvalue2.IsMatch(samphvalue))
                            {
                                if (samphvalue.ToLower() == "l")
                                {

                                    decimal temp = Convert.ToDecimal(valueall[j].monitorvalue);
                                    if (temp <= 0)
                                    {
                                        returntext = rule.JsonStr("error", "项目的检出限<=0,不能输入 L 作为监测值", "");
                                        return new HttpResponseMessage { Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json") };
                                    }
                                    dValue = -temp;
                                }
                                else
                                {
                                    dValue = -Convert.ToDecimal(samphvalue.Replace("l", "").Replace("L", ""));
                                }
                                if (dValue == -1)
                                {
                                    dValue = Convert.ToDecimal(-0.99999999);
                                }
                            }
                            else
                            {
                                dValue = Convert.ToDecimal(samphvalue);
                            }
                        }
                        #endregion
                        tblEQIW_R_Basedata_Pre objTmp = objData.Clone();
                        DateTime time = DateTime.Parse(valueall[j].fldDate.ToString());
                        objTmp.fldYear = time.Year;
                        objTmp.fldMonth = time.Month;
                        objTmp.fldDay = time.Day;
                        objTmp.fldHour = 0;
                        objTmp.fldMinute = 0;
                        objTmp.fldSAMPH = "1";
                        objTmp.fldRCode = valueall[j].fldRCode;
                        objTmp.fldRSCode = valueall[j].fldRSCode;
                        objTmp.fldSAMPR = "1";
                        objTmp.fldItemCode = inputdata[i].itemcode;
                        objTmp.fldItemValue = dValue;
                        lstData.Add(objTmp);
                    }
                }
                RuletblEQIW_R_Basedata_Pre rule_basedata = new RuletblEQIW_R_Basedata_Pre();
                bool issave = rule_basedata.InsertAll(lstData);
                if (issave)
                {
                    RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                    rule_wol.WriteLog(0, "录入河流数据到临时表", "", int.Parse(inputdata[0].fldUserID), int.Parse(inputdata[0].fldCityID_Operate));
                    returntext = rule.JsonStr("ok", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                }
                else
                {
                    returntext = rule.JsonStr("error", "保存数据失败!请重试!", "");
                }
            }
            catch (InputException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (InsertException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (Exception ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }

            return new HttpResponseMessage { Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json") };
        }
Example #5
0
        //
        public HttpResponseMessage PointSave(List <tbleqin_a_data> alldata)
        {
            string returntext = "";

            try
            {
                tblEQI_InputDate inputdate_new          = new tblEQI_InputDate();
                List <tblEQIN_A_BaseData_Pre> lstData   = new List <tblEQIN_A_BaseData_Pre>();
                List <inputeqin_a_data>       inputdata = alldata[0].inputdata;
                DateTime dts = DateTime.Parse(alldata[0].datetime);
                for (int i = 0; i < inputdata.Count; i++)
                {
                    tblEQIN_A_BaseData_Pre objData = new tblEQIN_A_BaseData_Pre();
                    objData.fldSTCode  = inputdata[i].fldSTCode;
                    objData.fldGDCODE  = inputdata[i].fldGDCODE;
                    objData.fldYear    = dts.Year;
                    objData.fldMonth   = dts.Month;
                    objData.fldDay     = dts.Day;
                    objData.fldHour    = dts.Hour.ToString() == "" ? -1 : Convert.ToDecimal(dts.Hour.ToString());
                    objData.fldMinute  = dts.Minute.ToString() == "" ? -1 : Convert.ToDecimal(dts.Minute.ToString());
                    objData.fldTimelen = inputdata[i].fldTimelen.ToString() == "" ? -1 : Convert.ToInt32(inputdata[i].fldTimelen.ToString());
                    objData.fldDN      = inputdata[i].fldDN.ToString();
                    objData.fldNDISC   = inputdata[i].fldNDISC.ToString();

                    objData.fldNSC             = inputdata[i].fldNSC.ToString();
                    objData.fldApparatus_Grade = inputdata[i].fldApparatus_Grade;

                    objData.fldLEQA = inputdata[i].fldLEQA.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldLEQA.ToString());
                    objData.fldL10A = inputdata[i].fldL10A.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldL10A.ToString());
                    objData.fldL50A = inputdata[i].fldL50A.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldL50A.ToString());
                    objData.fldL90A = inputdata[i].fldL90A.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldL90A.ToString());
                    objData.fldLmin = inputdata[i].fldLmin.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldLmin.ToString());
                    objData.fldLmax = inputdata[i].fldLmax.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldLmax.ToString());
                    objData.fldSD   = inputdata[i].fldSD.ToString() == "" ? -1 : Convert.ToDecimal(inputdata[i].fldSD.ToString());
                    objData.fldMph  = inputdata[i].fldMph.ToString() == "" ? -1 : decimal.Parse(inputdata[i].fldMph.ToString());

                    objData.fldApparatus_Type = inputdata[i].fldApparatus_Type.ToString();
                    objData.fldApparatus_Id   = inputdata[i].fldApparatus_Id.ToString();

                    objData.fldFlag                = 0;
                    objData.fldCityID_Operate      = int.Parse(alldata[0].CityID);
                    objData.fldCityID_Submit       = alldata[0].CityID;
                    objData.fldSource              = 0;
                    objData.fldImport              = 0;
                    objData.fldFlag                = 0;
                    objData.fldBatch               = "0";
                    objData.fldMatching_Data       = false;
                    objData.fldSPressureValue      = 0;
                    objData.fldCalibrationVluesEnd = 0;
                    objData.fldCalibrationVluesOn  = 0;
                    objData.fldDeleteState         = 0;
                    objData.fldSPressureType       = "0";
                    objData.fldSPressureID         = "0";
                    objData.fldDate_Operate        = DateTime.Now;
                    objData.fldUserID              = int.Parse(alldata[0].UserID);
                    lstData.Add(objData);
                    if (i == 0)
                    {
                        inputdate_new.fldSYear  = objData.fldYear;
                        inputdate_new.fldSMonth = objData.fldMonth;
                        inputdate_new.fldSDay   = objData.fldDay;
                        inputdate_new.fldCityID = objData.fldCityID_Operate;
                        inputdate_new.fldUserID = objData.fldUserID;
                        inputdate_new.fldObject = "eqin_a";
                    }
                }
                tblEQI_InputDate           inputdate_old = new tblEQI_InputDate();
                RuletblEQIN_A_Basedata_Pre rule_basedata = new RuletblEQIN_A_Basedata_Pre();
                bool issave = rule_basedata.InsertAll(lstData, inputdate_new, inputdate_old);
                if (issave)
                {
                    RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                    rule_wol.WriteLog(0, "录入区域噪声数据到临时表", "", int.Parse(alldata[0].UserID), int.Parse(alldata[0].CityID));
                    returntext = rule.JsonStr("ok", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                }
                else
                {
                    returntext = rule.JsonStr("error", "保存失败!请重试!", "");
                }
            }
            catch (InputException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (InsertException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (Exception ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json")
            });
        }
Example #6
0
        public string Update(string fldAutoId, string typemodel, string userId, string userName, string cityId, string NewFlag = null)
        {
            try
            {
                userId = rule.ConductUserinfo(userId);
                RuletblDictionary dic = new RuletblDictionary();
                if (typemodel.ToString() == "eqise")
                {
                    typemodel = "eqiw_r";
                }
                string list = dic.ByParentIDAndValue("数据审核视图", typemodel.ToString());

                string listone  = list.Split(',')[0].ToString().Substring(2);
                string listones = null;
                if (listone.ToLower().Contains("auto"))
                {
                    listones = listone.Substring(0, listone.Length - 12);
                }
                else
                {
                    listones = listone.Substring(0, listone.Length - 7);
                }
                string table = "";
                if (typemodel.ToString() == "eqib_v")
                {
                    table = "tbl_" + listones;
                }
                else
                {
                    table = "tbl" + listones;
                }


                List <long> lstDelID = new List <long>();
                string[]    fld      = fldAutoId.ToString().Split(',');
                for (int i = 0; i < fld.Length; i++)
                {
                    string[] pk = fld[i].Split('_');
                    for (int j = 0; j < pk.Length; j++)
                    {
                        lstDelID.Add(Convert.ToInt64(pk[j].ToString()));
                    }
                }
                RuletblEQIA_RPI_Basedata_Pre rule_basedata = new RuletblEQIA_RPI_Basedata_Pre();
                RuleWriteOperateLog          rule_wol      = new RuleWriteOperateLog();
                if (NewFlag == null)
                {
                    NewFlag = "1";
                }
                bool isb = rule_basedata.delBytable(lstDelID, table, NewFlag.ToString());
                if (isb)
                {
                    rule_wol.WriteLog(0, "提交审核选中的数据数据,进入监测数据审核状态录入这ID=" + userId.ToString(), userName.ToString(), int.Parse(userId.ToString()), int.Parse(cityId.ToString()));
                    return("提交审核数据成功!");
                }
                else
                {
                    return("提交审核数据失败,请重试!");
                }
            }
            catch (Exception e)
            {
                throw new Exception("提交审核数据失败!");
            }
        }
        /// <summary>
        /// 功能描述:数据插入到临时表
        /// 创建  人:周文卿
        /// 创建时间:2017/07/11
        /// 修改原因:
        /// 修改时间:
        /// 修改  人:
        /// </summary>
        /// <param name="inputdata">插入的实体类</param>
        /// <returns>json(是否成功)</returns>
        public HttpResponseMessage ItemSave(List <tbleqia_rd_table> inputdata)
        {
            string returntext = "";

            try
            {
                Regex regexvalue  = new Regex(@"^(\d*\.?\d+)+$");
                Regex regexvalue2 = new Regex(@"^(\d*\.?\d+)?[lL]$");
                List <tblEQIA_RDPI_Basedata_Pre> lstData = new List <tblEQIA_RDPI_Basedata_Pre>();
                tblEQIA_RDPI_Basedata_Pre        objData = new tblEQIA_RDPI_Basedata_Pre();
                tblEQI_InputDate inputdate_new           = new tblEQI_InputDate();
                RuletblEQI_publi ruleSense = new RuletblEQI_publi();
                for (int i = 0; i < inputdata.Count; i++)
                {
                    List <tbaeqia_rd_value> valueall = inputdata[i].valueall;
                    for (int j = 0; j < valueall.Count; j++)
                    {
                        RuletblDictionary ruleDict = new RuletblDictionary();

                        objData.fldSTCode         = valueall[j].fldSTCode;
                        objData.fldUserID         = int.Parse(inputdata[i].fldUserID);
                        objData.fldFlag           = 0;
                        objData.fldCityID_Operate = int.Parse(inputdata[i].fldCityID_Operate);
                        objData.fldCityID_Submit  = inputdata[i].fldCityID_Submit;
                        objData.fldDate_Operate   = DateTime.Now;
                        decimal dValue     = -1;
                        string  samphvalue = valueall[j].monitorvalue;
                        #region 因子值的处理
                        if (samphvalue != "")
                        {
                            if (regexvalue2.IsMatch(samphvalue))
                            {
                                if (samphvalue.ToLower() == "l")
                                {
                                    string itemname = "";
                                    itemname = ruleSense.GetSenseNameBytbl("EQIA_RD", inputdata[i].itemcode);
                                    decimal temp = Convert.ToDecimal(valueall[j].monitorvalue);
                                    if (temp <= 0)
                                    {
                                        returntext = "项目的检出限<=0,不能输入 L 作为监测值'";
                                    }
                                    dValue = -temp;
                                }
                                else
                                {
                                    dValue = -Convert.ToDecimal(samphvalue.Replace("l", "").Replace("L", ""));
                                }
                                if (dValue == -1)
                                {
                                    dValue = Convert.ToDecimal(-0.99999999);
                                }
                            }
                            else
                            {
                                dValue = Convert.ToDecimal(samphvalue);
                            }
                        }
                        #endregion
                        tblEQIA_RDPI_Basedata_Pre objTmp = objData.Clone();
                        objTmp.fldPCode = valueall[j].fldPCode;

                        DateTime time = DateTime.Parse(valueall[j].fldDate.ToString());
                        objTmp.fldSYear     = time.Year;
                        objTmp.fldSMonth    = time.Month;
                        objTmp.fldSDay      = time.Day;
                        objTmp.fldSHour     = 0;
                        objTmp.fldSMinute   = 0;
                        objTmp.fldEYear     = time.Year;
                        objTmp.fldEMonth    = time.Month;
                        objTmp.fldEDay      = time.Day;
                        objTmp.fldEHour     = 0;
                        objTmp.fldEMinute   = 0;
                        objTmp.fldFlag      = 0;
                        objTmp.fldImport    = 0;
                        objTmp.fldItemCode  = inputdata[i].itemcode;
                        objTmp.fldItemValue = dValue;
                        lstData.Add(objTmp);
                    }
                }
                RuletblEQIA_RDPI_Basedata_Pre rule_basedata = new RuletblEQIA_RDPI_Basedata_Pre();
                bool issave = rule_basedata.InsertAll(lstData);
                if (issave)
                {
                    RuleWriteOperateLog rule_wol = new RuleWriteOperateLog();
                    rule_wol.WriteLog(0, "录入降尘数据到临时表", "", int.Parse(inputdata[0].fldUserID), int.Parse(inputdata[0].fldCityID_Operate));
                    returntext = rule.JsonStr("ok", "录入成功!您保存的数据,已进入“待提交审核的数据”状态", "");
                }
                else
                {
                    returntext = rule.JsonStr("error", "录入失败 !请重试!", "");
                }
            }
            catch (InputException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (InsertException ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            catch (Exception ex)
            {
                returntext = rule.JsonStr("error", ex.Message, "");
            }
            return(new HttpResponseMessage {
                Content = new StringContent(returntext, System.Text.Encoding.UTF8, "application/json")
            });
        }