Exemplo n.º 1
0
        public async Task <ActionResult> Create(CreateCarouselModel model, string Submittype)
        {
            if (ModelState.IsValid)
            {
                var apimodel = new CreateCarouselModelNoFile
                {
                    Title         = model.Title,
                    Description   = model.Description,
                    Display       = model.Display,
                    DisplayDate   = model.DisplayDate,
                    TextLocation  = model.TextLocation,
                    FreeTextArea  = model.FreeTextArea,
                    CoverPictures = model.CoverPictures,
                    CreatedBy     = model.CreatedBy,
                    CreatedDate   = model.CreatedDate
                };

                if (model.CoverPictureFiles.Count() > 0)
                {
                    var files = await FileMethod.UploadFile(model.CoverPictureFiles.ToList(), CurrentUser.UserId, "carousel");

                    if (files != null)
                    {
                        apimodel.CoverFilesId = files.Select(f => f.Id).ToList();
                    }
                }

                var response = await WepApiMethod.SendApiAsync <string>(HttpVerbs.Post, $"Carousels/Carousel/Create", apimodel);

                if (response.isSuccess)
                {
                    string[] resparray = response.Data.Split('|');
                    string   newid     = resparray[0];
                    string   title     = resparray[1];

                    if ((model.CoverPictureFiles.Count() > 0))
                    {
                        await UploadImageFiles(int.Parse(newid), model.CoverPictureFiles.First());
                    }

                    await LogActivity(Modules.CarouselManagement, "Create New Carousel: " + title);

                    if (Submittype == "Save")
                    {
                        TempData["SuccessMessage"] = "New Carousel titled " + title + " created successfully and saved as draft.";

                        return(RedirectToAction("Index", "Carousel", new { area = "CarouselManagement" }));
                    }
                    else
                    {
                        return(RedirectToAction("Details", "Carousel", new { area = "CarouselManagement", @id = newid }));
                    }
                }
                else
                {
                    TempData["SuccessMessage"] = "Failed to create new Carousel.";

                    return(RedirectToAction("Index", "Carousel", new { area = "CarouselManagement" }));
                }
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(CreateCarouselModel model, string Submittype)
        {
            if (model.CoverPictures.Count() == 0 && model.CoverPictureFiles.Count() == 0)
            {
                ModelState.AddModelError("CoverPictures", "Please upload an image");
            }
            else
            {
                //validate file
                foreach (var file in model.CoverPictureFiles)
                {
                    if (!FileMethod.IsValidType(file, filter_imgs))
                    {
                        ModelState.AddModelError("CoverPictures", Language.Carousel.ValidAttachment);
                        break;
                    }
                }
            }

            if (ModelState.IsValid)
            {
                var apimodel = new CreateCarouselModel
                {
                    Id             = model.Id,
                    Title          = model.Title,
                    Description    = model.Description,
                    Display        = model.Display,
                    DisplayDate    = model.DisplayDate,
                    TextLocation   = model.TextLocation,
                    FreeTextArea   = model.FreeTextArea,
                    LastModifiedBy = CurrentUser.UserId,
                    CoverPictures  = model.CoverPictures
                };

                //attachment 1: cover pics
                if (model.CoverPictureFiles.Count() > 0)
                {
                    var files = await FileMethod.UploadFile(model.CoverPictureFiles.ToList(), CurrentUser.UserId, "carousel");

                    if (files != null)
                    {
                        apimodel.CoverFilesId = files.Select(f => f.Id).ToList();
                    }
                }

                var response = await WepApiMethod.SendApiAsync <string>(HttpVerbs.Post, $"Carousels/Carousel/Edit", apimodel);

                if (response.isSuccess)
                {
                    await LogActivity(Modules.CarouselManagement, "Edit Carousel: " + response.Data, model);

                    if (Submittype == "Save")
                    {
                        TempData["SuccessMessage"] = "Carousel titled " + response.Data + " updated successfully and saved as draft.";

                        return(RedirectToAction("Index", "Carousel", new { area = "CarouselManagement" }));
                    }
                    else
                    {
                        TempData["SuccessMessage"] = "Carousel titled " + response.Data + " updated successfully.";
                        return(RedirectToAction("Details", "Carousel", new { area = "CarouselManagement", @id = model.Id }));
                    }
                }
                else
                {
                    TempData["ErrorMessage"] = "Failed to edit Publication.";

                    return(RedirectToAction("Edit", "Carousel", new { area = "CarouselManagement", @id = model.Id }));
                }
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public Welcome(bool CheckUpdate)
        {
            //2012-09-03 LiuQi 启动时检查是否有word进程
            Process[] process;
            process = Process.GetProcesses();
            foreach (Process p in process)
            {
                try
                {
                    if (p.Id != 0 && p.Modules != null && p.Modules.Count > 0)
                    {
                        System.Diagnostics.ProcessModule pm = p.Modules[0];
                        if (pm.ModuleName.ToLower() == "winword.exe")
                        {
                            MessageBox.Show("其他程序影响电子病历正常使用须关闭!", "提示");
                            p.Kill();
                            break;
                        }
                    }
                }
                catch { }
            }
            InitializeComponent();
            //开始日志
            udt.jj.LoadlogAdapter();

            if (ini.ReadValue("System", "CheckClient").Trim() == true.ToString())
            {
                CheckClient();
            }

            try
            {
                tLoadData   = new Thread(LoadData);
                tShowStatus = new Thread(ShowStatus);
                if (ini.ReadValue("System", "LiveUpdate").Trim() == true.ToString())
                {
                    try
                    {
                        pUpdate.StartInfo.FileName  = Application.StartupPath + "\\liveupdate.exe";
                        pUpdate.StartInfo.Arguments = "-liveupdate[" + FileMethod.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + "]";
                        pUpdate.Start();
                    }
                    catch (Win32Exception)
                    {
                        ini.WriteValue("System", "LiveUpdate", false.ToString());
                        MessageBox.Show(this, "启动自动更新程序失败,自动更新功能已关闭,若要重新开启此功能请联系系统管理员或重新安装。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                    }
                }
                else
                {
                }

                ThisAddIn.logon = new Logon();
            }
            catch (Exception ex)
            {
                Globals.logAdapter.Record("EX756987457748", ex.Message + ">>" + ex.ToString(), true);

                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
 public void Demonstrate(FileMethod fileMethod)
 {
     typeof(Answers).GetMethod(fileMethod.ToString(), BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, null);
 }
        public static NetMQMessage GenerateFileModuleMethodMessage(int servermoduleID, int callID, FileMethod method)
        {
            var baseMessage = GenerateBaseMessage(servermoduleID, callID);

            //if (method is HelloWorldMethod _method)
            //{
            //    return GenerateHelloWorldMessage(_method);
            //}
            throw new MethodFailedException();
        }
Exemplo n.º 6
0
 public async Task <ActionResult> GetContent(int Id)
 {
     return(await FileMethod.DownloadFile(Id));
 }
Exemplo n.º 7
0
        public async Task <ActionResult> Edit(Models.EditKMCModel model)
        {
            if (model.IsPublic)
            {
                ModelState.Remove("RoleIds");
            }

            if (model.IsEditor)
            {
                ModelState.Remove("File");
                ModelState.Remove("Type");
            }
            else
            {
                ModelState.Remove("EditorCode");

                //validation of file type
                if (model.File != null)
                {
                    var isValid = true;

                    switch (model.Type)
                    {
                    case KMCType.Image:
                        isValid = FileMethod.IsValidType(model.File, filter_imgs);
                        break;

                    case KMCType.Video:
                        isValid = FileMethod.IsValidType(model.File, filter_videos);
                        break;

                    case KMCType.Audio:
                        isValid = FileMethod.IsValidType(model.File, filter_audios);
                        break;

                    case KMCType.Document:
                        isValid = FileMethod.IsValidType(model.File, filter_docs);
                        break;

                    case KMCType.Others:

                        break;

                    default:
                        break;
                    }

                    if (!isValid)
                    {
                        ModelState.AddModelError("File", Language.KMC.ValidIsValidTypeFile);
                    }
                }
                else
                {
                    if (model.FileId != null)
                    {
                        ModelState.Remove("File");
                    }
                }
            }

            if (ModelState.IsValid)
            {
                var modelapi = new EditKMCModel
                {
                    KMCCategoryId = model.CategoryId,
                    Title         = model.Title,
                    Description   = model.Description,
                    Type          = model.Type,
                    IsPublic      = model.IsPublic,
                    IsShow        = model.IsShow,
                    IsEditor      = model.IsEditor,
                    RoleIds       = model.RoleIds,
                    EditorCode    = model.EditorCode,
                    FileId        = model.IsEditor ? null : model.FileId,
                    ThumbnailUrl  = model.ThumbnailUrl
                };

                if (model.ThumbnailFile != null)
                {
                    var filename = FileMethod.SaveFile(model.ThumbnailFile, Server.MapPath("~/img/kmc-thumbnail"), model.ThumbnailUrl);
                    modelapi.ThumbnailUrl = filename;
                }

                if (model.File != null)
                {
                    var responseFile = await FileMethod.UploadFile(new List <HttpPostedFileBase> {
                        model.File
                    }, CurrentUser.UserId, "KMC/", model.File.ContentType);

                    if (responseFile != null)
                    {
                        modelapi.FileId   = responseFile.Select(f => f.Id).FirstOrDefault();
                        modelapi.FileType = model.File.ContentType;
                    }
                }

                var response = await WepApiMethod.SendApiAsync <bool>(HttpVerbs.Put, $"KMC/Manage?id={model.Id}", modelapi);

                if (response.isSuccess)
                {
                    if (!model.IsPublic && model.IsShow)//send notification
                    {
                        var userIds = new List <int>();

                        foreach (var roleId in model.RoleIds)
                        {
                            var responseUsers = await WepApiMethod.SendApiAsync <List <UserModel> >(HttpVerbs.Get, $"Administration/Role/GetAllUser?roleId={roleId}");

                            if (responseUsers.isSuccess)
                            {
                                userIds = userIds.Union(responseUsers.Data.Select(r => r.Id).ToList()).ToList();
                            }
                        }

                        if (userIds.Count > 0)
                        {
                            ParameterListToSend notificationParameter = new ParameterListToSend();
                            notificationParameter.Link = $"<a href = '" + BaseURL + "/KMC/Home/Browse/" + model.Id.ToString() + "' > here </a>";

                            CreateAutoReminder notification = new CreateAutoReminder
                            {
                                NotificationType      = NotificationType.KMCCreated,
                                NotificationCategory  = NotificationCategory.Learning,
                                ParameterListToSend   = notificationParameter,
                                StartNotificationDate = DateTime.Now,
                                ReceiverId            = userIds
                            };

                            var responseNotification = await WepApiMethod.SendApiAsync <ReminderResponse>(HttpVerbs.Post, $"Reminder/SLA/GenerateAutoNotificationReminder/", notification);
                        }
                    }

                    await LogActivity(Modules.KMC, "Edit KMC", model);

                    TempData["SuccessMessage"] = Language.KMC.AlertSuccessUpdate;

                    return(RedirectToAction("Details", "Manage", new { area = "KMC", @id = model.Id }));
                }
                else
                {
                    TempData["ErrorMessage"] = Language.KMC.AlertFailDelete;
                }
            }

            model.filter_imgs   = filter_imgs;
            model.filter_videos = filter_videos;
            model.filter_audios = filter_audios;
            model.filter_docs   = filter_docs;

            model.Roles = new SelectList(await GetRoles(), "Id", "Name", 0);

            return(View(model));
        }