示例#1
0
        public BizLogicMsg Save_Ext(JsonMCE_Meter_Check json)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_B_ASSETS_METER_CHECK entity = new EntityObject_MCE_B_ASSETS_METER_CHECK();

                            if (!string.IsNullOrEmpty(json.ID))
                            {
                                entity.ID = json.ID;

                                entity = HelperObject_MCE_B_ASSETS_METER_CHECK.Get(entity);

                                if (entity == null)
                                {
                                    throw new Exception("获取数据出错.");
                                }
                            }
                            else
                            {
                                throw new Exception("参数错误.");
                            }

                            if (!string.IsNullOrEmpty(json.ACTUAL_IDENTIFICATION))
                            {
                                entity.ACTUAL_IDENTIFICATION = DateTime.Parse(json.ACTUAL_IDENTIFICATION);
                            }

                            if (!string.IsNullOrEmpty(json.RESULT_ID))
                            {
                                entity.RESULT_ID = decimal.Parse(json.RESULT_ID);
                            }

                            entity.CERTIFICATE_CODE = json.CERTIFICATE_CODE;

                            if (!string.IsNullOrEmpty(json.MONEY))
                            {
                                entity.MONEY = decimal.Parse(json.MONEY);
                            }

                            entity.CHECK_PERSON = json.CHECK_PERSON;


                            entity.COMMENTS = json.COMMENTS;

                            int amount = HelperObject_MCE_B_ASSETS_METER_CHECK.Update(entity, transaction);


                            CauseObject_COM_FILE pCOM_FILE = new CauseObject_COM_FILE();
                            pCOM_FILE.REF_TAB_ID   = entity.ID;
                            pCOM_FILE.REF_TAB_NAME = "MCE_B_ASSETS_METER_CHECK";
                            HelperObject_COM_FILE.Delete(pCOM_FILE, transaction);


                            if (json.listAttach != null && json.listAttach.Count > 0)
                            {
                                foreach (JsonMCEMT_APPLY_MTN_ATTACH item in json.listAttach)
                                {
                                    Ipedf.Web.Entity.EntityObject_COM_FILE entityPicFile = new Ipedf.Web.Entity.EntityObject_COM_FILE();
                                    entityPicFile.REF_TAB_NAME   = "MCE_B_ASSETS_METER_CHECK";
                                    entityPicFile.CLIENT_NAME    = item.CLIENT_NAME;
                                    entityPicFile.STATE          = 1;
                                    entityPicFile.CREATE_TIME    = item.CREATE_TIME;
                                    entityPicFile.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                    entityPicFile.REF_TAB_ID     = entity.ID;
                                    entityPicFile.SERVER_NAME    = item.SERVER_NAME;
                                    entityPicFile.IS_IMPORT      = 0;
                                    Ipedf.Web.DataAccess.HelperObject_COM_FILE.Save(entityPicFile, transaction);
                                }
                            }


                            msg.Message = entity.ID;

                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            transaction.Rollback();
                            msg = new BizLogicMsg(false, expt.Message);
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(msg);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(json));
                }
            }
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;

                StringBuilder rsb       = new StringBuilder();
                int           bytelengg = (int)request.InputStream.Length;
                using (var reader = new StreamReader(request.InputStream, Encoding.UTF8))
                {
                    var read  = new Char[bytelengg];
                    var count = reader.Read(read, 0, bytelengg);
                    while (count > 0)
                    {
                        var str = new string(read, 0, count);
                        rsb.Append(str);
                        count = reader.Read(read, 0, bytelengg);
                    }
                    reader.Close();
                    reader.Dispose();
                    request.InputStream.Close();
                    request.InputStream.Dispose();
                }

                if (string.IsNullOrEmpty(rsb.ToString()))
                {
                    throw new Exception("参数错误.");
                }

                JsonMCE_Meter_Check entity = JsonConvert.DeserializeObject <JsonMCE_Meter_Check>(rsb.ToString());


                if (string.IsNullOrEmpty(entity.ACTUAL_IDENTIFICATION))
                {
                    throw new Exception("参数错误,实际检测日期不能为空.");
                }
                if (string.IsNullOrEmpty(entity.RESULT_ID) || entity.RESULT_ID == "0")
                {
                    throw new Exception("参数错误,检测结果不能为空.");
                }
                if (string.IsNullOrEmpty(entity.CHECK_PERSON))
                {
                    throw new Exception("参数错误,检测人不能为空.");
                }


                BizLogicMsg msg = BizLogicObject_MCE_B_ASSETS_METER_CHECK.Proxy.Save_Ext(entity);
                if (!msg.Succeed)
                {
                    throw new Exception(msg.Message);
                }

                jsonMsg.Succeed = 1;
                jsonMsg.Message = msg.Message;
                //jsonMsg.Message = "提交成功.";
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                context.Response.Write(JsonConvert.SerializeObject(jsonMsg));
                context.Response.End();
            }
        }