Esempio n. 1
0
        public override bool AddEntities(List <BuyInComing_Apply> ts)
        {
            List <BuyInComing_Apply> addApplies = new List <BuyInComing_Apply>();

            foreach (BuyInComing_Apply buyInComingApply in ts)
            {
                BuyInComing_Apply buyIn = GetEntity(m => m.Material_Id == buyInComingApply.Material_Id);
                if (buyIn != null)
                {
                    if (UnityContainerHelper.Server <IApplyInfoBll>().GetEntity(m => m.Apply_Id == buyIn.Id && m.Apply_Status == 0) != null)
                    {
                        buyInComingApply.Id = buyIn.Id;
                    }
                    else
                    {
                        addApplies.Add(buyInComingApply);
                    }
                }
                else
                {
                    addApplies.Add(buyInComingApply);
                }
            }

            return(base.AddEntities(addApplies));
        }
        public override BizObject GetParent()
        {
            IEngineeringVolumeService _IEngineeringVolumeService = UnityContainerHelper.GetServer <IEngineeringVolumeService>();
            var vol = _IEngineeringVolumeService.Get(this.VolumeID);

            return(new EngineeringVolumeInfo(vol));
        }
Esempio n. 3
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var _ITokenManager = UnityContainerHelper.GetServer <ITokenManager>();

            // 如果请求头中不包含 Authorization 内容,则抛出 401 异常,表明要访问的资源需要验证
            if (!actionContext.Request.Headers.Contains("Authorization"))
            {
                throw new Exception("请求头中未包含身份验证信息,拒绝访问");
            }

            // 获取请求头中的验证信息(即token)
            var jwtToken = actionContext.Request.Headers.GetValues("Authorization").First <string>();

            // 验证token
            HttpStatusCode statusCode = _ITokenManager.ValidateToken(jwtToken);

            // 验证通过(返回 http 200)则继续,否则抛出http错误
            if (statusCode == HttpStatusCode.OK)
            {
                base.OnActionExecuting(actionContext);
            }
            else
            {
                throw new Exception("身份验证失败,拒绝访问");
            }
        }
Esempio n. 4
0
        public static ProcessInfo GetFlowInfo(string System, string Key, int ID)
        {
            var _IObjectProcessService      = UnityContainerHelper.GetServer <IObjectProcessService>(System);
            var _IUserTaskService           = UnityContainerHelper.GetServer <IUserTaskService>(System);
            var _IBPMProcessInstanceService = UnityContainerHelper.GetServer <IBPMProcessInstanceService>();

            var objProcess  = _IObjectProcessService.Get(Key, ID);
            var processInfo = _IBPMProcessInstanceService.Get(objProcess.ProcessID);

            var result = new ProcessInfo();

            result.ProcessStatus = processInfo.Status;
            result.ProcessID     = processInfo.ID.ToString();
            if (processInfo.Status != (int)ProcessStatus.Finish)
            {
                var userTask = _IUserTaskService.GetCurrentTask(objProcess.ProcessID);

                result.CurrentTaskID   = userTask.Identity.ToString();
                result.CurrentTaskName = userTask.Name;
                result.CurrentTaskUser = userTask.UserID;
                result.CurrentTaskTime = userTask.Time;
            }

            return(result);
        }
Esempio n. 5
0
        public override bool AddEntities(List <Material_Apply> ts)
        {
            List <Material_Apply> applies   = new List <Material_Apply>();
            UnityContainerHelper  container = new UnityContainerHelper();

            foreach (var item in ts)
            {
                Material_Apply apply = GetEntity(m => string.Equals(m.Teacher_Id, item.Teacher_Id) &&
                                                 m.Apply_Time.Equals(item.Apply_Time) &&
                                                 m.Start_Time.Equals(item.Start_Time) &&
                                                 m.End_Time.Equals(item.End_Time) &&
                                                 string.Equals(m.Teach_Depart, item.Teach_Depart) &&
                                                 string.Equals(m.Teach_Field, item.Teach_Field) &&
                                                 string.Equals(m.Material_Id, item.Material_Id));
                if (apply != null)
                {
                    if (UnityContainerHelper.Server <IApplyInfoBll>().GetEntity(m => m.Apply_Id == apply.Id && m.Apply_Status == 0) != null)
                    {
                        item.Id = apply.Id;
                    }
                    else
                    {
                        applies.Add(item);
                    }
                }
                else
                {
                    applies.Add(item);
                }
            }

            return(base.AddEntities(applies));
        }
Esempio n. 6
0
        public static FlowDetailInfo GetFlowDetail(string System, string ObjectKey, int ObjectID)
        {
            var _IObjectProcessService = UnityContainerHelper.GetServer <IObjectProcessService>(System);
            var objProcess             = _IObjectProcessService.Get(ObjectKey, ObjectID);

            return(GetFlowDetail(System, objProcess.ProcessID.ToString()));
        }
Esempio n. 7
0
        public static Dictionary <string, Dictionary <string, Dictionary <string, string> > > GetFlowUser()
        {
            var _IBaseConfig = UnityContainerHelper.GetServer <IBaseConfig>();

            var nodes = _IBaseConfig.GetConfigNodes(c => c.Key.StartsWith("User.") && c.Key.EndsWith("Tasks"), "User.");

            var result = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();

            nodes.ForEach(user => {
                //  用户
                var users = new Dictionary <string, Dictionary <string, string> >();
                user.ChildNodes[0].ChildNodes.ForEach(spec => {
                    //  专业
                    var specs = new Dictionary <string, string>();
                    spec.ChildNodes[0].ChildNodes.ForEach(pro => {
                        //  流程
                        specs.Add(pro.NodeName, pro.ChildNodes[0].NodeValue);
                    });

                    users.Add(spec.NodeName, specs);
                });

                result.Add(user.NodeName, users);
            });

            return(result);
        }
Esempio n. 8
0
        public void Run()
        {
            var             path      = ConfigurationManager.AppSettings["ContainerConfigPath"];
            IUnityContainer container = UnityContainerHelper.Create(path);

            InstanceLocator.SetLocator(new MyInstanceLocator(container));
        }
        protected override void Initialize()
        {
            TypeRegistrationTrackerExtension.RegisterIfMissing(Container);

            m_CompositionContainer = PrepareCompositionContainer();

            Debug.Assert(Container == Context.Container);

            Debug.Assert(Container.IsTypeRegistered(typeof(CompositionContainer))
                         == Container.IsRegistered <CompositionContainer>());

            Debug.Assert(Container.IsTypeRegistered(typeof(CompositionContainer))
                         == UnityContainerHelper.IsTypeRegistered(Container, typeof(CompositionContainer)));

//#if true || NET40
//            if (!Container.IsTypeRegistered(typeof(CompositionContainer)))
//            {
//                Context.Container.RegisterInstance(typeof(CompositionContainer), m_CompositionContainer);
//            }

//            //IServiceLocator locator = ServiceLocator.Current;
//#else
//            Context.Locator.Add(typeof(CompositionContainer), m_CompositionContainer);
//#endif

            Context.Policies.SetDefault <ICompositionContainerPolicy>(new CompositionContainerPolicy(m_CompositionContainer));
            Context.Strategies.AddNew <CompositionStrategy>(UnityBuildStage.TypeMapping);
            Context.Strategies.AddNew <ComposeStrategy>(UnityBuildStage.Initialization);
        }
Esempio n. 10
0
        private async Task <HttpResponseMessage> getResponse2()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var file = new FileStream(attach.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

                // 判断是否大于64Md,如果大于就采用分段流返回,否则直接返回
                if (file.Length < MEMORY_SIZE)
                {
                    //Copy To Memory And Close.
                    byte[] bytes = new byte[file.Length];
                    await file.ReadAsync(bytes, 0, (int)file.Length);

                    file.Close();
                    MemoryStream ms = new MemoryStream(bytes);

                    response.Content = new ByteArrayContent(ms.ToArray());
                }
                else
                {
                    response.Content = new StreamContent(file);
                }

                if (attach.Type == (int)EnumAttachType.Excel)
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                }
                else if (attach.Type == (int)EnumAttachType.PPT)
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.presentationml.presentation");
                }
                else
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
                }

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Esempio n. 11
0
        public static async Task <UploadResponseModel> Upload(HttpRequestMessage Request, string Name)
        {
            if (Request.Content.IsMimeMultipartContent())
            {
                var uploadPath = System.Configuration.ConfigurationManager.AppSettings["UploadFilePath"];

                var date = DateTime.Now;

                var fullPath = Path.Combine(uploadPath, date.Year.ToString(), date.Month.ToString(), date.Day.ToString());

                if (!Directory.Exists(fullPath))
                {
                    Directory.CreateDirectory(fullPath);
                }

                var _IImageGetter  = UnityContainerHelper.GetServer <IImageGetter>();
                var response       = new UploadResponseModel();
                var streamProvider = new UploadStreamProvider(fullPath);
                var upResult       = await Request.Content.ReadAsMultipartAsync(streamProvider);

                foreach (var file in upResult.FileData)
                {
                    var stream = new FileStream(file.LocalFileName, FileMode.Open);
                    var md5Str = Md5.GetMd5Hash(stream);
                    stream.Close();

                    FileInfo fi     = new FileInfo(file.LocalFileName);
                    var      entity = _IImageGetter.SaveImage(streamProvider.FileName, streamProvider.MediaType, Name, md5Str, fi);

                    // 检查文件的MD5 如果有相同的MD5文件,则直接返回已有的文件ID
                    // var entity = _IImageGetter.Check(md5Str);
                    //if (entity == null)
                    //{
                    //    FileInfo fi = new FileInfo(file.LocalFileName);
                    //    entity = _IImageGetter.SaveImage(streamProvider.FileName, streamProvider.MediaType, Name, md5Str, fi);
                    //}

                    response.files.Add(new FileResponseModel()
                    {
                        id         = entity.ID,
                        name       = entity.Name,
                        size       = entity.Size,
                        error      = "",
                        mediaType  = streamProvider.MediaType,
                        type       = entity.Extension,
                        upDateTime = entity.UploadDate.ToString("yyyy-MM-dd hh:mm:ss")
                    });
                }

                return(response);
            }
            else
            {
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid Request!");
                throw new HttpResponseException(response);
            }
        }
Esempio n. 12
0
        //public ProcessEngine()
        //{
        //    this._ProcessInstances = new Dictionary<string, ProcessInstance>();
        //    this.modelInstanceIDMaps = new Dictionary<string, string>();
        //}

        public string CreateProcessInstance(string Identity, int User, Dictionary <string, object> InputData = null)
        {
            // 获取流程模板
            var def = ProcessModelCache.Instance[Identity];

            // 获取流程的监听者
            var _Ob = UnityContainerHelper.GetServer <IObservation>(def.ProcessOb.Name);

            var pID = Guid.NewGuid().ToString();

            // 生成流程实例
            var pi = new ProcessInstance()
            {
                ID   = pID,
                Name = def.ID,
            };

            pi.StartDate  = DateTime.Now;
            pi.Version    = 1;
            pi.CreateUser = User;
            pi.InputData  = InputData;

            // 流程资源
            def.Resources.ForEach(r =>
            {
                var prs = new ProcessResouce()
                {
                    Key   = r.ID,
                    Users = new Dictionary <string, string>()
                };

                r.Users.ForEach(u =>
                {
                    prs.Users.Add(u.ID, u.Name);
                });

                pi.ProcessResouces.Add(r.ID, prs);
            });

            // 编译脚本代码
            if (!string.IsNullOrEmpty(def.ConditionCode))
            {
                pi.Compiled = ConditionExpression.Evaluator(def.ConditionCode, def.ID);
            }

            // 生成流程脚本实例
            pi.GeneratTasks(def, InputData, _Ob);

            // 缓存流程实例
            _ProcessInstances.Add(pID, pi);

            // 保存生成的流程实例
            BPMDBService.Create(pi);

            return(pID);
        }
Esempio n. 13
0
        public async Task Next(string System, int ID, Dictionary <string, object> Datas)
        {
            var _IUserTaskService = UnityContainerHelper.GetServer <IUserTaskService>(System);

            var taskID = _IUserTaskService.Get(ID).Identity;

            Datas.Add("userTaskID", ID);

            await ProcessEngine.Instance.Continu(taskID.ToString(), int.Parse(base.User.Identity.Name), Datas);
        }
Esempio n. 14
0
        protected void Application_Start()
        {
            IUnityContainer         unityContainer    = UnityContainerHelper.InitUnityContainer();
            UnityDependencyResolver dependencyRcolver = new UnityDependencyResolver(unityContainer);

            DependencyResolver.SetResolver(dependencyRcolver);
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Esempio n. 15
0
        public override List <BPMTaskInstanceEntity> GetTasks()
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();
            var _IObjectProcessService   = UnityContainerHelper.GetServer <IObjectProcessService>("System3");

            var processInfo = _IObjectProcessService.Get(base.ObjectKey, this.ID);

            this.Tasks = _IBPMTaskInstanceService.GetList(t => t.ProcessID == processInfo.ProcessID && t.Type == (int)TaskType.Manual && !t.IsDelete);

            return(this.Tasks);
        }
Esempio n. 16
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IEngineeringSpecialtyService _IEngineeringSpecialtyService = UnityContainerHelper.GetServer <IEngineeringSpecialtyService>();
            IEngineeringResourceService  _IEngineeringResourceService  = UnityContainerHelper.GetServer <IEngineeringResourceService>();

            var specils  = _IEngineeringSpecialtyService.GetEngineeringSpecialtys(this.ID);
            var resource = _IEngineeringResourceService.GetEngineeringResource(this.ID);

            specils.AddRange(resource);

            return(specils);
        }
Esempio n. 17
0
        public static FlowNodeInfo GetInitFlowNodeInfo(string FlowName, Dictionary <string, Object> Params = null)
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();

            var def = ProcessModelCache.Instance[FlowName];

            var node = new FlowNodeInfo();

            var list = getFlowTasks(def.Process).Take(2).ToList();

            node.CurrentTaskName = list.First().Name;

            if (list.Count == 2)
            {
                node.NextName       = list.Last().Name;
                node.NextIsJoinSign = list.Last().IsJoinSign;
                node.NextOwner      = list.Last().Owner;

                // 不是会签才取候选人
                if (!node.NextIsJoinSign)
                {
                    node.NextUsers = new List <int>();

                    var owner = list.Last().Owner;

                    def.Resources.ForEach(r =>
                    {
                        if (r.ID == owner)
                        {
                            if (r.IOwner != null)
                            {
                                var call = UnityContainerHelper.GetServer <IOwner>(r.IOwner.Name);

                                node.NextUsers = call.GetOwner("_" + list[1].DefID, Params);
                            }

                            node.NextUsers = node.NextUsers ?? new List <int>();

                            r.Users.ForEach(u =>
                            {
                                var id = int.Parse(u.ID);
                                if (!node.NextUsers.Contains(id))
                                {
                                    node.NextUsers.Add(id);
                                }
                            });
                        }
                    });
                }
            }

            return(node);
        }
Esempio n. 18
0
        private async Task <HttpResponseMessage> downloadSingleFile()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var file = new FileStream(attach.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

                // 判断是否大于64Md,如果大于就采用分段流返回,否则直接返回
                if (file.Length < MEMORY_SIZE)
                {
                    //Copy To Memory And Close.
                    byte[] bytes = new byte[file.Length];
                    await file.ReadAsync(bytes, 0, (int)file.Length);

                    file.Close();
                    MemoryStream ms = new MemoryStream(bytes);

                    response.Content = new ByteArrayContent(ms.ToArray());
                }
                else
                {
                    response.Content = new StreamContent(file);
                }

                //response.Content = new StreamContent(System.IO.File.OpenRead(attach.Path));
                response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attach");
                response.Content.Headers.ContentDisposition.FileName = attach.Name;


                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Esempio n. 19
0
        public static void RegisterComponents()
        {
            //var container = new UnityContainer();


            var container = UnityContainerHelper.GetContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();

            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
Esempio n. 20
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IEngineeringVolumeService _IEngineeringVolumeService = UnityContainerHelper.GetServer <IEngineeringVolumeService>();

            var volumes = _IEngineeringVolumeService.GetSpecialtyVolumesV2(this.EngineeringID, this.SpecialtyID, PageParam != null && PageParam.FilterCondtion.ContainsKey("Task"));

            var result = new List <BizObject>();

            foreach (var item in volumes)
            {
                result.Add(item);
            }

            return(result);
        }
Esempio n. 21
0
        public static int CreateChatGroup(ChatGroupInfo GroupInfo)
        {
            var _Context = new SystemContext();

            var entity = new ChatGroupEntity()
            {
                GroupName   = GroupInfo.GroupName,
                GroupDesc   = GroupInfo.GroupDesc,
                CreateDate  = DateTime.Now,
                CreateEmpID = GroupInfo.CreateEmpID,
                IsDelete    = false,
                IsPublic    = false
            };

            _Context.ChatGroupEntity.Add(entity);
            _Context.SaveChanges();

            // 将自己添加进组成员
            _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
            {
                GroupID = entity.GroupID,
                EmpID   = GroupInfo.CreateEmpID
            });

            foreach (var id in GroupInfo.Emps)
            {
                if (id != GroupInfo.CreateEmpID)
                {
                    _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
                    {
                        GroupID = entity.GroupID,
                        EmpID   = id
                    });
                }
            }

            _Context.SaveChanges();

            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 104
            });

            return(entity.GroupID);
        }
Esempio n. 22
0
        public static void UpdateChatGroup(int GroupID, ChatGroupInfo GroupInfo)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEntity.Find(GroupID);

            entity.GroupName = GroupInfo.GroupName;
            entity.GroupDesc = GroupInfo.GroupDesc;

            _Context.Entry(entity).State = System.Data.Entity.EntityState.Modified;

            // 先清空小组成员
            var items = _Context.ChatGroupEmpsEntity.Where(g => g.GroupID == GroupID);

            foreach (var item in items)
            {
                _Context.ChatGroupEmpsEntity.Remove(item);
            }

            // 重新生成小组成员
            _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
            {
                GroupID = entity.GroupID,
                EmpID   = entity.CreateEmpID
            });

            foreach (var id in GroupInfo.Emps)
            {
                if (id != GroupInfo.CreateEmpID)
                {
                    _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
                    {
                        GroupID = entity.GroupID,
                        EmpID   = id
                    });
                }
            }

            _Context.SaveChanges();
            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 104
            });
        }
Esempio n. 23
0
        public static void ExitChatGroup(int GroupID, int UserID)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEmpsEntity.SingleOrDefault(g => g.GroupID == GroupID && g.EmpID == UserID);

            _Context.ChatGroupEmpsEntity.Remove(entity);

            _Context.SaveChanges();
            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                TargetUser  = UserID,
                MessageType = 106
            });
        }
Esempio n. 24
0
        public static FlowDetailInfo GetFlowDetail(string System, string ProcessID)
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();

            var _IUserTaskService = UnityContainerHelper.GetServer <IUserTaskService>(System);

            var tasks = _IBPMTaskInstanceService.GetList(t => t.ProcessID == new Guid(ProcessID) &&
                                                         !t.IsDelete && (t.Type == (int)TaskType.Manual || t.Type == (int)TaskType.Sign));


            var taskLog = _IUserTaskService.GetTaskLog(new Guid(ProcessID));

            return(new FlowDetailInfo()
            {
                Logs = taskLog,
                Tasks = tasks
            });
        }
Esempio n. 25
0
        public static void RemoveChatGroup(int GroupID)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEntity.Find(GroupID);

            entity.IsDelete = true;

            _Context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
            _Context.SaveChanges();

            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 105
            });
        }
Esempio n. 26
0
        private HttpResponseMessage downloadFiles()
        {
            if (!string.IsNullOrEmpty(FileIds))
            {
                var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();
                this.Attachs = _IImageGetter.GetAttachs(this.FileIds);
            }

            // 这里按照ID排序,以便生成的下载临时压缩文件的文件名ID有序
            this.Attachs = this.Attachs.OrderBy(a => a.ID).ToList();

            var zipContent = ZipFileHelp.ZipFileByCode(this.Attachs);
            var response   = new HttpResponseMessage();

            response.Content = new StreamContent(zipContent);
            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = DateTime.Now.ToFileTime().ToString() + ".zip";

            return(response);
        }
Esempio n. 27
0
        public async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            //if (System.IO.File.Exists(filePath))
            //{
            //    HttpResponseMessage response = new HttpResponseMessage();
            //    response.Content = new StreamContent(System.IO.File.OpenRead(filePath));
            //    response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");

            //    return await Task.FromResult(response);
            //}

            var attach = _IImageGetter.GetAttach(this.ImageID);

            HttpResponseMessage response = new HttpResponseMessage();

            if (attach != null && attach.Type == (int)EnumAttachType.Picture && System.IO.File.Exists(attach.Path))
            {
                response.Content = new StreamContent(System.IO.File.OpenRead(attach.Path));
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("image/" + attach.Extension.Trim('.'));

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", ImageID));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(await Task.FromResult(response));
        }
Esempio n. 28
0
        private HttpResponseMessage getResponse()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var stream = WordGenerator.ConvertHtml(attach.Path);

                // 把图片的绝对路径替换成网络路径
                var htmlStr = Encoding.UTF8.GetString(stream.ToArray());
                htmlStr = htmlStr.Replace(AppDomain.CurrentDomain.BaseDirectory, "http://localhost:8002/");
                byte[] bytes = Encoding.UTF8.GetBytes(htmlStr);

                response.Content = new ByteArrayContent(bytes);
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("text/html");

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Esempio n. 29
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IFormChangeService _IFormChangeService = UnityContainerHelper.GetServer <IFormChangeService>();
            var result = _IFormChangeService.GetVolumeChanges(this.ID);

            IEngineeringVolumeCheckService _IEngineeringVolumeCheckService = UnityContainerHelper.GetServer <IEngineeringVolumeCheckService>();
            var checkList = _IEngineeringVolumeCheckService.GetVolumeCheckList(this.ID);

            if (checkList.Count > 0)
            {
                result.Add(new EngineeringVolumeCheckForm()
                {
                    ID         = this.ID,
                    ObjectText = "校审单",
                    VolumeID   = this.ID,
                    Checker    = this.Checker,
                    Designer   = this.Designer,
                    CheckItems = checkList
                });
            }

            return(result);
        }
Esempio n. 30
0
        public ActionResult History(DateTime?Apply_Time, DateTime?Start_Time, DateTime?End_Time)
        {
            var cookie = Request.Cookies["userInfo"];

            if (cookie != null)
            {
                ViewBag.applyTime = Apply_Time;
                ViewBag.startTime = Start_Time;
                ViewBag.endTime   = End_Time;
                string           name        = cookie.Value;
                var              user        = JsonConvert.DeserializeObject <UserInfo>(UrlHelper.DecodeUrl(name));
                string           teacherName = UnityContainerHelper.Server <ITeacherBll>().Find(user.username).Teacher_Name;
                List <Use_Apply> applies     = _useApplyBll.GetEntities(
                    m => m.Teacher_Name == teacherName &&
                    (Apply_Time == null || m.Apply_Time == Apply_Time) &&
                    (Start_Time == null || m.Start_Time == Start_Time) &&
                    (End_Time == null || m.End_Time == End_Time)
                    );
                return(View(applies));
            }

            return(Content("登录信息失效,请重新登录"));
        }