public ActionResult GetColumnsItems(string[] columns)
        {
            List <Language> list = new List <Language>();

            list = ILanguages.GetAll().ToList();
            var column = new List <String>();

            for (int i = 0; i < list.Count; i++)
            {
                if (!list[i].LanguageCode.Equals("en"))
                {
                    column.Add(list[i].LanguageName.ToString());
                }
            }
            var col = column.ToArray();

            columns = columns ?? col;
            object value = null;

            if (Session["SelectedColumns"] != null)
            {
                value = (string[])Session["SelectedColumns"];
            }

            //return Json(columns.Select(o => new KeyContent(o, o)));
            return(Json(new AweItems
            {
                Items = columns.Select(o => new KeyContent(o, o)),
                Value = value
            }));
        }
        public ActionResult GetAllMissingTranslations(GridParams g)
        {
            var items              = Ilanguages.GetAll().AsQueryable();
            List <languages> data  = new List <languages>();
            AdminController  admin = new AdminController();

            foreach (var column in items)
            {
                System.Data.DataTable table = admin.getTable();
                for (int i = table.Rows.Count - 1; i >= 0; i--)
                {
                    // whatever your criteria is

                    if (table.Rows[i][column.LanguageName].ToString() != "")
                    {
                        table.Rows[i].Delete();
                    }
                }
                languages a = new languages();
                a.Id                      = Convert.ToInt32(column.Id);
                a.LanguageCode            = column.LanguageCode;
                a.LanguageName            = column.LanguageName;
                a.MissingTranslationCount = table.Rows.Count;
                data.Add(a);
            }

            var key   = Convert.ToInt32(g.Key);
            var model = new GridModelBuilder <languages>(data.AsQueryable(), g)
            {
                Key     = "Id",
                GetItem = () => data.Single(x => x.Id == key)
            }.Build();

            return(Json(model));
        }
        public ActionResult DownloadPoFile(HttpPostedFileBase postedFile, string pagename)
        {
            ViewBag.errormsgexport = "";
            if (postedFile != null)
            {
                string fileextension = System.IO.Path.GetExtension(postedFile.FileName);
                if (fileextension != ".po")
                {
                    ViewBag.errormsgexport = "File format is not .po";
                }
                else
                {
                    string path = System.IO.Path.Combine(Server.MapPath("~/Content/Export/"));
                    System.IO.Directory.CreateDirectory(path);
                    string filepath = path + postedFile.FileName;
                    var    filename = System.IO.Path.GetFileNameWithoutExtension(filepath);
                    if (System.IO.File.Exists(filepath))
                    {
                        System.IO.File.Delete(filepath);
                    }
                    postedFile.SaveAs(filepath);
                    List <Language> list = new List <Language>();
                    list = ILanguages.GetAll().ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var Languagecode = list[i].LanguageCode;

                        var input = System.IO.File.ReadAllText(filepath);
                        sbPo = new StringBuilder();
                        using (var sr = new StreamReader(filepath, Encoding.UTF8))
                            this.LoadFromReader(sr, "Export", Languagecode, filename);
                    }
                    string SourceFolderPath = System.IO.Path.Combine(path, "Initial");

                    Response.Clear();
                    Response.ContentType = "application/zip";
                    Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", "Languages" + ".zip"));

                    bool recurseDirectories = true;
                    using (ZipFile zip = new ZipFile())
                    {
                        zip.AddSelectedFiles("*", path, string.Empty, recurseDirectories);
                        zip.Save(Response.OutputStream);
                    }
                    Response.End();

                    System.IO.Directory.Delete(path, true);
                    ViewBag.errormsgexport = "File downloaded successfully.";
                }
            }
            else
            {
                ViewBag.errormsgexport = "Please Select File";
            }

            if (pagename == "Index")
            {
                ViewBag.pageName = "Index";
                return(View("Index", "_AdminLayout"));
            }
            else
            {
                ViewBag.pageName = "embeded";
                return(View("Index", "_LayoutEmbedAdmin"));
            }
        }
Ejemplo n.º 4
0
        public ActionResult GetAllLanguages()
        {
            var items = Ilanguages.GetAll().ToList();

            return(Json(items.Select(o => new KeyContent(o.LanguageCode, o.LanguageName))));
        }