示例#1
0
        public ActionResult _FolderSetting()
        {
            FolderLocation folderLocation = new FolderLocation();
            DataSet        ds             = _userData.GetFolderLocation(Session["BPID"].ToString(), "select");

            if (ds.Tables[0].Rows.Count > 0)
            {
                ViewBag.source     = ds.Tables[0].Rows[0]["Source"].ToString();
                ViewBag.target     = ds.Tables[0].Rows[0]["Target"].ToString();
                ViewBag.convertion = ds.Tables[0].Rows[0]["Conversion"].ToString();
                ViewBag.filter     = ds.Tables[0].Rows[0]["Filter"].ToString();
                ViewBag.archive    = ds.Tables[0].Rows[0]["Archive"].ToString();
                ViewBag.template   = ds.Tables[0].Rows[0]["Template"].ToString();
                ViewBag.report     = ds.Tables[0].Rows[0]["Report"].ToString();
                ViewBag.changelog  = ds.Tables[0].Rows[0]["Changelog"].ToString();
                ViewBag.errorlog   = ds.Tables[0].Rows[0]["Errorlog"].ToString();
            }
            else
            {
                ViewBag.source     = DefaultFolderLocation.Source;
                ViewBag.target     = DefaultFolderLocation.Target;
                ViewBag.convertion = DefaultFolderLocation.Conversion;
                ViewBag.filter     = DefaultFolderLocation.Filter;
                ViewBag.archive    = DefaultFolderLocation.Archive;
                ViewBag.template   = DefaultFolderLocation.Template;
                ViewBag.report     = DefaultFolderLocation.Report;
                ViewBag.changelog  = DefaultFolderLocation.Changelog;
                ViewBag.errorlog   = DefaultFolderLocation.Errorlog;
            }
            return(PartialView("_FolderSetting"));
        }
示例#2
0
    public static string[] GetFilesFromStringPath(string filePath, FolderLocation fld)
    {
        string[] paths = new string[1];

        try
        {
            if (filePath != "")
            {
                for (int i = 0; i < 1; i++)
                {
                    if (filePath.Contains("Could not find file"))
                    {
                        filePath = filePath.Replace("Could not find file", "").TrimEnd('.');
                    }

                    string fileName = Path.GetFileName(filePath);


                    string path = HttpContext.Current.Server.MapPath("~/" + fld.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-"));

                    string ext = Path.GetExtension(filePath);

                    string random    = Common.GetRandomString();
                    string fullPath  = path + "/" + fileName.Replace(ext, "") + "~" + random + ext;
                    string Shortpath = fld.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-") + "/" + fileName.Replace(ext, "") + "~" + random + ext;


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

                    if (!File.Exists(fullPath))
                    {
                        File.Copy(filePath, fullPath);

                        paths[i] = Shortpath;
                    }
                    else
                    {
                        File.Copy(filePath, fullPath);
                        paths[i] = Shortpath;
                    }
                }
            }
        }
        catch (Exception ex)
        {
        }
        return(paths);
    }
示例#3
0
        public static string[] UpLoadNew(FileUpload fld, FolderLocation location)
        {
            string[] paths = new string[fld.PostedFiles.Count];
            if (fld.HasFile)
            {
                int iUploadedCnt = 0;


                for (int i = 0; i < fld.PostedFiles.Count; i++)
                {
                    HttpPostedFile uploadfile = fld.PostedFiles[i];
                    string         fileName   = Path.GetFileName(uploadfile.FileName);
                    string         path       = HttpContext.Current.Server.MapPath("~/" + location.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-"));

                    string ext = Path.GetExtension(uploadfile.FileName);

                    string random    = Common.GetRandomString();
                    string fullPath  = path + "/" + fileName.Replace(ext, "") + "~" + random + ext;
                    string Shortpath = location.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-") + "/" + fileName.Replace(ext, "") + "~" + random + ext;
                    if (uploadfile.ContentLength > 0)
                    {
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        if (!File.Exists(fullPath))
                        {
                            uploadfile.SaveAs(fullPath);
                            paths[i]      = Shortpath;
                            iUploadedCnt += 1;
                        }
                        else
                        {
                            File.Delete(fullPath);
                            uploadfile.SaveAs(fullPath);
                            paths[i] = Shortpath;
                        }
                    }
                }
                string msg = iUploadedCnt.ToString() + "  Files Upload Successfully..!!";
            }
            return(paths.ToArray());
        }
示例#4
0
        public ActionResult UpadateRestoreFolderLoc(string op, FolderLocation folderLocation)
        {
            int            rValue        = 0;
            FolderLocation restoreFolder = new FolderLocation();
            string         data          = "Update data";
            string         BPID          = Session["BPID"].ToString();

            if (op == "restore")
            {
                // Restore from constant
                restoreFolder.BPID       = BPID;
                restoreFolder.Source     = DefaultFolderLocation.Source;
                restoreFolder.Target     = DefaultFolderLocation.Target;
                restoreFolder.Conversion = DefaultFolderLocation.Conversion;
                restoreFolder.Filter     = DefaultFolderLocation.Filter;
                restoreFolder.Archive    = DefaultFolderLocation.Archive;
                restoreFolder.Template   = DefaultFolderLocation.Template;
                restoreFolder.Report     = DefaultFolderLocation.Report;
                restoreFolder.Changelog  = DefaultFolderLocation.Changelog;
                restoreFolder.Errorlog   = DefaultFolderLocation.Errorlog;
            }
            else
            {
                // Update with new one
                restoreFolder.BPID       = BPID;
                restoreFolder.Source     = folderLocation.Source;
                restoreFolder.Target     = folderLocation.Target;
                restoreFolder.Conversion = folderLocation.Conversion;
                restoreFolder.Filter     = folderLocation.Filter;
                restoreFolder.Archive    = folderLocation.Archive;
                restoreFolder.Template   = folderLocation.Template;
                restoreFolder.Report     = folderLocation.Report;
                restoreFolder.Changelog  = folderLocation.Changelog;
                restoreFolder.Errorlog   = folderLocation.Errorlog;
            }
            rValue = _userData.UpdateFolderLocation(restoreFolder, "insert");
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
示例#5
0
    public static string[] GetFilesFromStringPathMultiple(string[] filePath, FolderLocation fld)
    {
        string[] paths = new string[filePath.Length];

        if (filePath.Length > 0)
        {
            for (int i = 0; i < filePath.Length; i++)
            {
                string fileName = Path.GetFileName(filePath[i]);
                string path     = HttpContext.Current.Server.MapPath("~/" + fld.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-"));

                string ext = Path.GetExtension(filePath[i]);

                string random    = Common.GetRandomString();
                string fullPath  = path + "/" + fileName.Replace(ext, "") + "~" + random + ext;
                string Shortpath = fld.ToString() + "/" + DateTime.Now.Date.ToString("dd/MM/yyyy").Replace("/", "-") + "/" + fileName.Replace(ext, "") + "~" + random + ext;


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

                if (!File.Exists(fullPath))
                {
                    File.Copy(filePath[i], fullPath);

                    paths[i] = Shortpath;
                }
                else
                {
                    File.Copy(filePath[i], fullPath);
                    paths[i] = Shortpath;
                }
            }
        }
        return(paths);
    }