コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string result = string.Empty;

            if (string.IsNullOrEmpty(context.Request["CopyEntities"]))
            {
                result = "请勾选实体!";
            }
            if (string.IsNullOrEmpty(context.Request["Categories"]))
            {
                result += "请选择目标类别!";
            }
            if (string.IsNullOrEmpty(result))
            {
                string[] ids = context.Request["CopyEntities"].Trim().Split(',');
                if (context.Request["Move"] == "true")
                {
                    result = CheckEntityChildren.CheckSelectMoveEntities(ids);
                }
                else
                {
                    result = CheckEntityChildren.CheckSelectEntities(ids);
                }

                string[] categories = context.Request["Categories"].Trim().Split(',');
                if (string.IsNullOrEmpty(result))
                {
                    try
                    {
                        if (context.Request["Move"] == "true")
                        {
                            DEObjectOperations.InstanceWithPermissions.MoveEntities(ids.ToList(), categories.ToList());
                        }
                        else
                        {
                            DEObjectOperations.InstanceWithPermissions.CopyEntities(ids.ToList(), categories.ToList());
                        }
                    }
                    catch (Exception e)
                    {
                        result = e.Message;
                    }
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["CopyEntities"]))
            {
                string[] ids = context.Request["CopyEntities"].Trim().Split(',');
                if (context.Request["Move"] == "true")
                {
                    result = CheckEntityChildren.CheckSelectMoveEntities(ids);
                }
                else
                {
                    result = CheckEntityChildren.CheckSelectEntities(ids);
                }
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
コード例 #3
0
        //导出
        protected void btn_Export_Click(object sender, EventArgs e)
        {
            var req = Request;

            if (req.IsAuthenticated)
            {
                //var entityIDs = hd_entityID.Value.Split(',').Where(p => p.IsNotEmpty()).ToList();
                var entityIDs = ProcessDescInfoDeluxeGrid.SelectedKeys;

                if (!entityIDs.Any())
                {
                    return;
                }

                ETLEntityCollection collection = new ETLEntityCollection();
                try
                {
                    entityIDs.ForEach(id => collection.Add(DESchemaObjectAdapter.Instance.Load(id, DateTime.Now.SimulateTime()) as ETLEntity));
                    //验证导出数据的完整性
                    string validResult = CheckEntityChildren.CheckSelectEntities(collection.Select(p => p.ID).ToArray());
                    validResult.IsNotEmpty().TrueThrow(validResult);

                    string fileName = "ETLEntity" + "_" + DateTime.Now.SimulateTime().ToString("yyyyMMdd_HHmmss") + ".xml";
                    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + ResponseExtensions.EncodeFileNameInContentDisposition(Response, fileName) + "\"");

                    var aaa = collection.ToXElement();
                    Response.Write(aaa.ToString());
                    Response.Flush();
                    Response.End();
                }
                catch (Exception ex)
                {
                    var exception = ex.GetRealException();
                    throw new HttpException("导出实体出错!\r\n" + exception.Message, ex.InnerException);
                }
            }
            else
            {
                throw new HttpException("请求的方式错误");
            }
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            var req = context.Request;

            if (req.IsAuthenticated)
            {
                var entityIDs = req.QueryString["id"].Split('|').Where(p => p.IsNotEmpty()).ToList();
                DynamicEntityCollection collection = new DynamicEntityCollection();
                try
                {
                    entityIDs.ForEach(id => collection.Add(DESchemaObjectAdapter.Instance.Load(id, DateTime.Now.SimulateTime()) as DynamicEntity));
                    //验证导出数据的完整性
                    string validResult = CheckEntityChildren.CheckSelectEntities(collection.Select(p => p.ID).ToArray());
                    validResult.IsNotEmpty().TrueThrow(validResult);

                    string fileName = "DynamicEntity" + "_" + DateTime.Now.SimulateTime().ToString("yyyyMMdd_HHmmss") + ".xml";
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + MCS.Web.Library.ResponseExtensions.EncodeFileNameInContentDisposition(context.Response, fileName) + "\"");

                    XmlWriter writer = XmlWriter.Create(context.Response.Output);
                    writer.WriteStartDocument();

                    collection.ToXElement().WriteTo(writer);
                    writer.WriteEndDocument();

                    writer.Close();
                }
                catch (Exception ex)
                {
                    var exception = ex.GetRealException();
                    throw new HttpException("导出实体出错!\r\n" + exception.Message, ex.InnerException);
                }
            }
            else
            {
                throw new HttpException("请求的方式错误");
            }
        }