コード例 #1
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
        public ActionResult Customize_Progress_Bar(string myuploader)
        {
            using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
            {
                uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
                //the data of the uploader will render as <input type='hidden' name='myuploader'>
                uploader.Name = "myuploader";
                uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar";

                uploader.InsertText = "Select a file to upload";

                //prepair html code for the view
                ViewData["uploaderhtml"] = uploader.Render();

                //if it's HTTP POST:
                if (!string.IsNullOrEmpty(myuploader))
                {
                    //for single file , the value is guid string
                    Guid fileguid = new Guid(myuploader);
                    CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                    if (file != null)
                    {
                        //you should validate it here:
                        //now the file is in temporary directory, you need move it to target location
                        //file.MoveTo("~/myfolder/" + file.FileName);
                        //set the output message
                        ViewData["UploadedMessage"] = "The file " + file.FileName + " has been processed.";
                    }
                }
            }
            return(View());
        }
コード例 #2
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
 public ActionResult Persist_upload_file(string myuploader)
 {
     using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
     {
         uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
         //the data of the uploader will render as <input type='hidden' name='myuploader'>
         uploader.Name = "myuploader";
         uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar";
         uploader.MaxSizeKB             = 10240;
         //tell uploader attach a button
         uploader.InsertText = "Upload File";
         //prepair html code for the view
         ViewData["uploaderhtml"] = uploader.Render();
         //if it's HTTP POST:
         if (!string.IsNullOrEmpty(myuploader))
         {
             List <string> processedfiles = new List <string>();
             //for multiple files , the value is string : guid/guid/guid
             foreach (string strguid in myuploader.Split('/'))
             {
                 Guid fileguid = new Guid(strguid);
                 CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                 if (file != null)
                 {
                     processedfiles.Add(file.FileName);
                 }
             }
             if (processedfiles.Count > 0)
             {
                 ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed.";
             }
         }
     }
     return(View());
 }
コード例 #3
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
        public ActionResult FilesUploadAjax(string guidlist, string deleteid)
        {
            FileManagerProvider manager = new FileManagerProvider();
            string username             = GetCurrentUserName();

            if (!string.IsNullOrEmpty(guidlist))
            {
                using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
                {
                    foreach (string strguid in guidlist.Split('/'))
                    {
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(new Guid(strguid));
                        if (file == null)
                        {
                            continue;
                        }
                        //savefile here
                        manager.MoveFile(username, file.GetTempFilePath(), file.FileName, null);
                    }
                }
            }

            if (!string.IsNullOrEmpty(deleteid))
            {
                FileItem file = manager.GetFileByID(username, deleteid);
                if (file != null)
                {
                    file.Delete();
                }
            }

            FileItem[] files = manager.GetFiles(username);
            Array.Reverse(files);
            FileManagerJsonItem[] items = new FileManagerJsonItem[files.Length];
            string baseurl = Response.ApplyAppPathModifier("~/FileManagerDownload.ashx?user="******"&file=");

            for (int i = 0; i < files.Length; i++)
            {
                FileItem            file = files[i];
                FileManagerJsonItem item = new FileManagerJsonItem();
                item.FileID      = file.FileID;
                item.FileName    = file.FileName;
                item.Description = file.Description;
                item.UploadTime  = file.UploadTime.ToString("yyyy-MM-dd HH:mm:ss");
                item.FileSize    = file.FileSize;
                item.FileUrl     = baseurl + file.FileID;
                items[i]         = item;
            }
            JsonResult json = new JsonResult();

            json.Data = items;
            return(json);
        }
コード例 #4
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
        public ActionResult Drag_drop_file(string myuploader)
        {
            using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
            {
                uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
                //the data of the uploader will render as <input type='hidden' name='myuploader'>
                uploader.Name = "myuploader";
                uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar";
                uploader.MaxSizeKB             = 1024;
                uploader.ManualStartUpload     = true;
                uploader.InsertText            = "Browse Files (Max 1M)";

                uploader.MultipleFilesUpload = true;
                uploader.InsertButtonID      = "InsertButton";
                uploader.QueuePanelID        = "QueuePanel";
                //uploader.FileDropPanelID = "DropPanel";

                //prepair html code for the view
                ViewData["uploaderhtml"] = uploader.Render();

                //if it's HTTP POST:
                if (!string.IsNullOrEmpty(myuploader))
                {
                    string msgs = "";
                    foreach (string guidstr in myuploader.Split('/'))
                    {
                        //for single file , the value is guid string
                        Guid fileguid = new Guid(guidstr);
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                        if (file != null)
                        {
                            //you should validate it here:
                            //now the file is in temporary directory, you need move it to target location
                            //file.MoveTo("~/myfolder/" + file.FileName);
                            //set the output message
                            msgs += "The file " + file.FileName + " has been processed.\r\n";
                        }
                    }
                    ViewData["UploadedMessage"] = msgs;
                }
            }
            return(View());
        }
コード例 #5
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
 public ActionResult selecting_multiple_files(string myuploader)
 {
     using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
     {
         uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
         //the data of the uploader will render as <input type='hidden' name='myuploader'>
         uploader.Name = "myuploader";
         uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar";
         //allow select multiple files
         uploader.MultipleFilesUpload = true;
         //tell uploader attach a button
         uploader.InsertButtonID = "uploadbutton";
         //prepair html code for the view
         ViewData["uploaderhtml"] = uploader.Render();
         //if it's HTTP POST:
         if (!string.IsNullOrEmpty(myuploader))
         {
             List <string> processedfiles = new List <string>();
             //for multiple files , the value is string : guid/guid/guid
             foreach (string strguid in myuploader.Split('/'))
             {
                 Guid fileguid = new Guid(strguid);
                 CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                 if (file != null)
                 {
                     //you should validate it here:
                     //now the file is in temporary directory, you need move it to target location
                     //file.MoveTo("~/myfolder/" + file.FileName);
                     processedfiles.Add(file.FileName);
                 }
             }
             if (processedfiles.Count > 0)
             {
                 ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed.";
             }
         }
     }
     return(View());
 }
コード例 #6
0
ファイル: DemoController.cs プロジェクト: R0manych/VG-project
        public ActionResult FileUploadAjaxWithoutSave(string guidlist, string limitcount, string hascount)
        {
            List <FileManagerJsonItem> items = new List <FileManagerJsonItem>();
            int maxcount   = 0;
            int existcount = 0;

            int.TryParse(hascount, out existcount);
            int.TryParse(limitcount, out maxcount);
            if (!string.IsNullOrEmpty(guidlist))
            {
                using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
                {
                    int ix = 0;
                    foreach (string strguid in guidlist.Split('/'))
                    {
                        if (maxcount > 0 && ix + existcount >= maxcount)
                        {
                            break;
                        }
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(new Guid(strguid));
                        if (file == null)
                        {
                            continue;
                        }
                        ix++;
                        FileManagerJsonItem item = new FileManagerJsonItem();
                        item.FileID   = file.FileGuid.ToString();
                        item.FileName = file.FileName;
                        item.FileSize = file.FileSize;
                        items.Add(item);
                    }
                }
            }
            JsonResult json = new JsonResult();

            json.Data = items;
            return(json);
        }
コード例 #7
0
        public ActionResult Upload(string myuploader, string description, string documentId)
        {
            Guid serviceOrderReportId = Guid.Empty;
            Guid? documentIdReal = null;
            if (!String.IsNullOrEmpty(documentId))
                documentIdReal = new Guid(documentId);
            //Get the service order identifier
            if (Session["serviceOrderReportId"] != null)
            {
                serviceOrderReportId = new Guid(Session["serviceOrderReportId"].ToString());
            }
            using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
            {
                if (!string.IsNullOrEmpty(myuploader))
                {
                    List<string> processedfiles = new List<string>();
                    //for multiple files , the value is string : guid/guid/guid
                    foreach (string strguid in myuploader.Split('/'))
                    {
                        //for single file , the value is guid string
                        Guid fileguid = new Guid(strguid);
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                        if (file != null)
                        {
                            //Save the document in the database
                            PictureDocumentBusiness.SaveDocument(file, documentIdReal, description, UserName, serviceOrderReportId);
                            processedfiles.Add(file.FileName);
                            file.Delete();
                        }
                    }

                    if (processedfiles.Count > 0)
                    {
                        ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed.";
                    }
                }
            }

            return RedirectToAction("Index");
        }
コード例 #8
0
 /// <summary>
 /// add new pictures to an inspection report
 /// </summary>
 /// <param name="myuploader">pictures</param>
 /// <param name="serviceOrderId">Id of service order</param>
 /// <param name="inspectionReportItemId">Id of inspection report</param>
 public void UploadNewPictures(string myuploader, Guid? serviceOrderId, Guid? inspectionReportItemId)
 {
     using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
     {
         if (!string.IsNullOrEmpty(myuploader))
         {
             List<string> processedfiles = new List<string>();
             //for multiple files , the value is string : guid/guid/guid
             foreach (string strguid in myuploader.Split('/'))
             {
                 //for single file , the value is guid string
                 Guid fileguid = new Guid(strguid);
                 CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                 if (file != null)
                 {
                     //Save the picture in the database
                     PictureDocumentBusiness.UploadPicture(file, serviceOrderId.GetValueOrDefault(), UserName, inspectionReportItemId);
                     processedfiles.Add(file.FileName);
                     file.Delete();
                 }
             }
             if (processedfiles.Count > 0)
                 ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed.";
         }
     }
 }
コード例 #9
0
        public ActionResult SaveInspectionReport(FormCollection collection)
        {
            if (collection.AllKeys.Contains("serviceOrderId")) collection.Remove("serviceOrderId");
            InspectionReportModel model = Session["frmNewInspection"] as InspectionReportModel;
            Guid serviceOrderReportId = new Guid(Session["serviceOrderReportId"].ToString());
            Guid businessApplicationId = new Guid(Convert.ToString(Session["BusinessAplicationId"]));
            Guid inspectionReportItemId = Guid.Empty;
            string publishValidate = string.Empty;
            string myuploader = string.Empty;
            //validate form and business rules
            if (model.ScreenOpenMode != ScreenOpenMode.View)
            {
                ValidateForm(model.FormDefinition, collection);
                ValidateBusinessRules(model.FormDefinition, collection);
            }
            if (ModelState.IsValid)
            {
                //if publish or validate button is clicked, take the value and remove the key from the collection
                if (collection.AllKeys.Contains("PublishValidateOption") && !string.IsNullOrEmpty(collection["PublishValidateOption"]))
                    publishValidate = collection["PublishValidateOption"];
                collection.Remove("PublishValidateOption");

                if(collection.AllKeys.Contains("UploadLib_Uploader_js"))
                    collection.Remove("UploadLib_Uploader_js");

                if (collection.AllKeys.Contains("__RequestVerificationToken"))
                    collection.Remove("__RequestVerificationToken");

                if (collection.AllKeys.Contains("myuploader"))
                {
                    myuploader = collection["myuploader"].ToString();
                    collection.Remove("myuploader");
                }

                //Set parameters for the method
                ParameterSaveInspectionReport parameters = new ParameterSaveInspectionReport
                {
                    BusinessApplicationId = businessApplicationId,
                    FormCollection = collection,
                    InspectionReportName = model.GridColumns.FormName,
                    ServiceOrderId = serviceOrderReportId,
                    UserName = UserName,
                    RolesForUser = Roles.GetRolesForUser(UserName).ToList(),
                    IsClient = User.IsInRole("Client")
                };
                if (model.ScreenOpenMode == ScreenOpenMode.Add)
                   inspectionReportItemId =  InspectionReportBusiness.AddInspectionReport(parameters);
                else if (model.ScreenOpenMode == ScreenOpenMode.Edit)
                {
                    inspectionReportItemId = new Guid(Session["inspectionReportItemId"].ToString());
                    parameters.InspectionReportItemId = inspectionReportItemId;

                    //perform edit operation
                    InspectionReportBusiness.EditInspectionReport(parameters);
                    //publish or validate inspection report item
                    if (!string.IsNullOrEmpty(publishValidate))
                        InspectionReportBusiness.PublishValidateInspectionReport(inspectionReportItemId, UserName);

                }
                else if (model.ScreenOpenMode == ScreenOpenMode.View && !string.IsNullOrEmpty(publishValidate) && publishValidate == "UnPublish")
                {
                    //Get the id of inspection report item
                    inspectionReportItemId = new Guid(Session["inspectionReportItemId"].ToString());
                    //Perform unpublish operation
                    InspectionReportBusiness.UnPublishInspectionReport(inspectionReportItemId, UserName, Roles.GetRolesForUser(UserName).ToList());
                }
                else if (model.ScreenOpenMode == ScreenOpenMode.View && !string.IsNullOrEmpty(publishValidate) && (publishValidate == "Publish" || publishValidate == "Validate"))
                {
                    //Get the id of inspection report item
                    inspectionReportItemId = new Guid(Session["inspectionReportItemId"].ToString());
                    //Perform unpublish operation
                    InspectionReportBusiness.PublishValidateInspectionReport(inspectionReportItemId, UserName);
                }

                if (!string.IsNullOrEmpty(myuploader) && model.ScreenOpenMode == ScreenOpenMode.Add)
                {
                    using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
                    {
                        if (!string.IsNullOrEmpty(myuploader))
                        {
                            List<string> processedfiles = new List<string>();
                            //for multiple files , the value is string : guid/guid/guid
                            foreach (string strguid in myuploader.Split('/'))
                            {
                                //for single file , the value is guid string
                                Guid fileguid = new Guid(strguid);
                                CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
                                if (file != null)
                                {
                                    //Save the picture in the database
                                    PictureDocumentBusiness.UploadPicture(file, serviceOrderReportId, UserName, inspectionReportItemId);
                                    processedfiles.Add(file.FileName);
                                    file.Delete();
                                }
                            }
                            if (processedfiles.Count > 0)
                                ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed.";
                        }
                    }
                }

                return RedirectToAction("ChangeReport", "InspectionReport");
            }
            else
            {
                return View("InspectionReport", model);
            }
        }