Beispiel #1
0
        public string SaveXml(string dateXml, string userXml)
        {
            HttpResult hr = new HttpResult() { Result = true };

            try
            {
                EsbInvoker esbInvokerEntity = XmlDataEntity.ConvertXmlToSingle<EsbInvoker>(dateXml);
                EsbUsers user = userXml.FromXml<EsbUsers>();

                using (ConnectionScope scope = new ConnectionScope(TransactionMode.Required))
                {
                    if (esbInvokerEntity.InvokerID == Guid.Empty)
                    {
                        if (EntityCommon.IsExistData("Esb_Invoker", "InvokerCode", esbInvokerEntity.InvokerCode))
                        {
                            hr.Result = false;
                            hr.ErrorMessage = "用户代码不允许重复,请重新录入用户代码!";
                            return hr.ToXml();
                        }
                        esbInvokerEntity.InvokerID = Guid.NewGuid();
                        esbInvokerEntity.CreatedOn = DateTime.Now;
                        esbInvokerEntity.CreatedBy = user.UserID;

                        esbInvokerEntity.Insert();
                    }
                    else
                    {
                        esbInvokerEntity.ModifiedOn = DateTime.Now;
                        esbInvokerEntity.ModifiedBy = user.UserID;
                        esbInvokerEntity.Update();
                    }

                    hr.KeyValue = esbInvokerEntity.InvokerID.ToString();
                    scope.Commit();
                }
            }
            catch (Exception)
            {
                hr.Result = false;
                hr.ErrorMessage = "运行时异常,请与管理员联系!";
            }

            return hr.ToXml();
        }