示例#1
0
        public JsonResult SaveResource(string uploadFiles, int sortId, int isOpen, int canDownload, string tags, string memo)
        {
            try
            {
                var list      = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(uploadFiles);
                var resources = new List <KL_Resource>();
                foreach (var res in list)
                {
                    var item = new KL_Resource();
                    item.IsManagerUpload = 0;

                    item.UserId         = CurrentUser.UserId;
                    item.TenantId       = CurrentTenant.TenantId;
                    item.LastUpdateTime = DateTime.Now;
                    item.CreateTime     = DateTime.Now;
                    item.IsDeleted      = 0;
                    item.FileId         = res.Path;
                    item.CanDownload    = canDownload;
                    item.IsOpen         = isOpen;
                    item.Tags           = tags;
                    item.Memo           = memo;
                    item.SortId         = sortId;
                    item.ResourceName   = res.FileName;
                    item.RealName       = res.RealName;
                    item.Lookup         = item.ResourceName.GetPy() + " " + item.ResourceName.GetPy(2);

                    item.ExtendName = res.ExtendName;
                    item.FileSize   = res.FileSize;
                    if (item.IsOpen == 0)
                    {
                        item.Status = 1;
                    }

                    item.Path = res.Path + ".swf";

                    //new RabbitMQHelper(Rabbit_serverAddress, Rabbit_userName, Rabbit_password, Rabbit_fileTrans,
                    //  Rabbit_queue).SendMessage(new FileModel
                    //  {
                    //      SourcePath = Server.MapPath(item.RealName),
                    //      TargetPath = Server.MapPath(item.Path)
                    //  });
                    resources.Add(item);
                }
                _resourceManager.AddResources(resources);
                #region 积分

                for (int i = 0; i < resources.Count; i++)
                {
                    RetechWing.BusinessCommon.Integration.IntegrationManager.Instence.FireIntegrationEvent(RetechWing.BusinessCommon.Integration.IntegrationEvents.UploadKnowledge, CurrentUser.UserId, CurrentTenant.TenantId);
                }
                #endregion

                return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public JsonResult SaveResource(string data, int isOpen, string userIds)
        {
            try
            {
                var list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <KL_Resource> >(data);
                foreach (var item in list)
                {
                    item.IsManagerUpload = 1;

                    item.UserId         = CurrentUser.UserId;
                    item.TenantId       = CurrentTenant.TenantId;
                    item.LastUpdateTime = DateTime.Now;
                    item.CreateTime     = DateTime.Now;
                    item.IsDeleted      = 0;
                    item.IsOpen         = string.IsNullOrEmpty(userIds) ? item.IsOpen : 2;
                    item.Lookup         = item.ResourceName.GetPy() + " " + item.ResourceName.GetPy(2);
                    item.Path           = item.RealName + ".swf";
                }
                _resourceManager.AddResources(list);

                #region 积分

                RetechWing.BusinessCommon.Integration.IntegrationManager.Instence.FireIntegrationEvent(RetechWing.BusinessCommon.Integration.IntegrationEvents.UploadKnowledge, CurrentUser.UserId, CurrentTenant.TenantId);

                #endregion

                if (isOpen == 1)
                {
                    var users     = userIds.GetArray();
                    var openusers = new List <KL_KnowledgeOpenUser>();
                    foreach (var resource in list)
                    {
                        for (int i = 0; i < users.Length; i++)
                        {
                            var openUser = new KL_KnowledgeOpenUser
                            {
                                ResourceId = resource.ResourceId,
                                UserId     = users[i]
                            };
                            openusers.Add(openUser);
                        }
                    }
                    if (openusers.Count > 0)
                    {
                        _resourceManager.AddResourceOpenUsers(openusers);
                    }
                }

                return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet));
            }
        }