Beispiel #1
0
        public BizLogicMsg Save_TypeDept(JsonMceType jsonMceType)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            if (jsonMceType.listDeptID != null && jsonMceType.listDeptID.Count > 0)
                            {
                                foreach (string strDeptID in jsonMceType.listDeptID)
                                {
                                    CauseObject_MCE_D_TYPE_DEPT p_Type = new CauseObject_MCE_D_TYPE_DEPT();

                                    p_Type.MCE_TYPE_ID = jsonMceType.id;
                                    p_Type.DEPT_ID     = strDeptID;

                                    DisplayObject_MCE_D_TYPE_DEPT[] list = BizLogicObject_MCE_D_TYPE_DEPT.Proxy.Query(p_Type);

                                    if (list == null || list.Length == 0)
                                    {
                                        EntityObject_MCE_D_TYPE_DEPT item = new EntityObject_MCE_D_TYPE_DEPT();
                                        item.MCE_TYPE_ID = jsonMceType.id;
                                        item.DEPT_ID     = strDeptID;
                                        HelperObject_MCE_D_TYPE_DEPT.Save(item, transaction);
                                    }
                                }
                            }


                            //平台自动生成代码

                            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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.Save_TypeDept(jsonMceType));
                }
            }
        }
Beispiel #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;

                //  string strID = request["id"].ToString();


                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("参数错误.");
                }

                JsonMceType jsonMceType = JsonConvert.DeserializeObject <JsonMceType>(rsb.ToString());

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

                if (jsonMceType.listDeptID == null || jsonMceType.listDeptID.Count == 0)
                {
                    throw new Exception("请选择科室.");
                }


                BizLogicMsg msg = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Save_TypeDept(jsonMceType);
                if (!msg.Succeed)
                {
                    throw new Exception(msg.Message);
                }

                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                context.Response.Write(JsonConvert.SerializeObject(jsonMsg));
                context.Response.End();
            }
        }
Beispiel #3
0
        public BizLogicMsg Save_Ext(JsonMceType jsonMceType)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_D_MCE_TYPE obj = new EntityObject_MCE_D_MCE_TYPE();

                            obj.CODE      = jsonMceType.code;
                            obj.NAME      = jsonMceType.name;
                            obj.PARENT_ID = jsonMceType.parent_id;
                            obj.STATE     = jsonMceType.state;

                            if (string.IsNullOrEmpty(jsonMceType.id))
                            {
                                obj.CREATE_TIME    = DateTime.Now;
                                obj.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                int amount = HelperObject_MCE_D_MCE_TYPE.Save(obj, transaction);
                            }
                            else
                            {
                                obj.ID = jsonMceType.id;
                                int amount = HelperObject_MCE_D_MCE_TYPE.Update(obj, transaction);

                                /*
                                 * CauseObject_MCE_D_TYPE_DEPT cause = new CauseObject_MCE_D_TYPE_DEPT();
                                 * cause.MCE_TYPE_ID = jsonMceType.id;
                                 * int amount1 = HelperObject_MCE_D_TYPE_DEPT.Delete(cause, transaction);
                                 */
                            }

                            /*
                             * if (jsonMceType.listDeptID != null && jsonMceType.listDeptID.Count>0)
                             * {
                             *  foreach (string strDeptID in jsonMceType.listDeptID)
                             *  {
                             *      EntityObject_MCE_D_TYPE_DEPT item = new EntityObject_MCE_D_TYPE_DEPT();
                             *      item.MCE_TYPE_ID =  obj.ID;
                             *      item.DEPT_ID = strDeptID;
                             *      HelperObject_MCE_D_TYPE_DEPT.Save(item, transaction);
                             *  }
                             *
                             * }
                             */

                            //平台自动生成代码

                            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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(jsonMceType));
                }
            }
        }
Beispiel #4
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;

                //  string strID = request["id"].ToString();


                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("参数错误.");
                }

                JsonMceType jsonMceType = JsonConvert.DeserializeObject <JsonMceType>(rsb.ToString());

                if (string.IsNullOrEmpty(jsonMceType.parent_id) || string.IsNullOrEmpty(jsonMceType.code) || string.IsNullOrEmpty(jsonMceType.name) || jsonMceType.state <= 0)
                {
                    throw new Exception("父类、类型编码、类型名称、状态不能为空.");
                }


                CauseObject_MCE_D_MCE_TYPE p = new CauseObject_MCE_D_MCE_TYPE();
                p.CODE = jsonMceType.code;


                string strCondition = "";
                if (!string.IsNullOrEmpty(jsonMceType.id))
                {
                    strCondition = strCondition + " and MCE_D_MCE_TYPE.ID<>'" + jsonMceType.id + "'";
                    p.SetCustomCondition(strCondition);
                }


                DisplayObject_MCE_D_MCE_TYPE[] list = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p);
                if (list != null && list.Length > 0)
                {
                    throw new Exception("分类编码:[" + jsonMceType.code + "]已经存在.");
                }

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

                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                context.Response.Write(JsonConvert.SerializeObject(jsonMsg));
                context.Response.End();
            }
        }