コード例 #1
0
 public void Remove(MsgTbl msg)
 {
     if (Context.Entry(msg).State == EntityState.Detached)
     {
         context.MsgTbl.Attach(msg);
     }
     context.MsgTbl.Remove(msg);
 }
コード例 #2
0
 public DbEntityEntry <MsgTbl> Entry(MsgTbl msg)
 {
     return(Context.Entry(msg));
 }
コード例 #3
0
 public void Attach(MsgTbl msg)
 {
     context.MsgTbl.Attach(msg);
 }
コード例 #4
0
 public void Add(MsgTbl msg)
 {
     context.MsgTbl.Add(msg);
 }
コード例 #5
0
        public ActionResult AddTrls()
        {
            var message = "OK";
            List <ErrorMessage> errorMessages = new List <ErrorMessage>();
            List <Error>        errors        = new List <Error>();
            List <MsgTbl>       msgstable     = new List <MsgTbl>();
            var    Source      = new DataSource <MsgTblViewModel>();
            string culture     = Language;
            var    root        = Server.MapPath("~/").Replace("WebApp", "Db");
            string Path1       = root + "Persistence\\Repositories";
            var    Folder      = System.AppDomain.CurrentDomain.BaseDirectory + "Controllers";
            var    directories = Directory.GetDirectories(System.AppDomain.CurrentDomain.BaseDirectory + "Views");

            FileInfo[][]  arr = new FileInfo[2 + directories.Length][];
            DirectoryInfo di  = new DirectoryInfo(Folder);
            DirectoryInfo di1 = new DirectoryInfo(Path1);

            arr[0] = di1.GetFiles("*.cs");
            arr[1] = di.GetFiles("*.cs");
            for (int i = 2; i < arr.Length - 2; i++)
            {
                DirectoryInfo x = new DirectoryInfo(directories[i]);
                arr[i] = x.GetFiles("*.cshtml");
            }
            for (int i = 0; i < arr.Length; i++)
            {
                FileInfo[] file = arr[i];
                if (file != null)
                {
                    foreach (var item in file)
                    {
                        string[] f        = System.IO.File.ReadAllText(item.FullName).Split(';');
                        var      trlsList = f.Where(j => j.Contains("Trls"));
                        if (trlsList != null)
                        {
                            foreach (var trls in trlsList)
                            {
                                int index = trls.IndexOf("Trls(");
                                if (index != -1 && trls.IndexOf("MsgUtils.Instance.Trls") != -1)
                                {
                                    var b = Regex.Matches(trls.Substring(index), "\"(.+?)\"");
                                    if (b.Count > 0)
                                    {
                                        string key  = Regex.Matches(trls.Substring(index), "\"(.+?)\"")[0].Value.ToString().Replace("\"", "").TrimEnd();
                                        var    exit = _hrUnitOfWork.Repository <MsgTbl>().Where(a => a.Name == key && a.Culture == culture).FirstOrDefault();
                                        if (exit == null)
                                        {
                                            var msg = new MsgTbl
                                            {
                                                Culture = culture,
                                                Name    = key,
                                            };
                                            if (!msgstable.Exists(a => a.Name == msg.Name))
                                            {
                                                msgstable.Add(msg);
                                                _hrUnitOfWork.AudiTrialRepository.Add(msg);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Source.Errors = SaveChanges(Language);
            if (Source.Errors.Count > 0)
            {
                foreach (var item in msgstable)
                {
                    if (item.Name.Length > 30)
                    {
                        message = item.Name;
                        return(Json(message, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public ActionResult CreateMsgTbl(IEnumerable <MsgTblViewModel> models, string culture)
        {
            var result     = new List <MsgTbl>();
            var datasource = new DataSource <MsgTblViewModel>();

            datasource.Data  = models;
            datasource.Total = models.Count();

            if (ModelState.IsValid)
            {
                if (ServerValidationEnabled)
                {
                    var errors = _hrUnitOfWork.MenuRepository.Check(new CheckParm
                    {
                        CompanyId  = CompanyId,
                        ObjectName = "MsgTbl",
                        TableName  = "MsgTbls",
                        Columns    = Models.Utils.GetModifiedRows(ModelState),
                        Culture    = Language
                    });
                }

                foreach (MsgTblViewModel p in models)
                {
                    var msg = new MsgTbl
                    {
                        Culture    = culture,
                        JavaScript = p.JavaScript,
                        Meaning    = p.Meaning,
                        Name       = p.Name
                    };
                    result.Add(msg);
                    _hrUnitOfWork.AudiTrialRepository.Add(msg);
                }

                datasource.Errors = SaveChanges(Language);
            }
            else
            {
                datasource.Errors = Utils.ParseErrors(ModelState.Values);
            }

            datasource.Data = (from p in models
                               join r in result on new { p.Culture, p.Name } equals new { r.Culture, r.Name }
                               select new MsgTblViewModel
            {
                Id = r.SequenceId,
                Name = r.Name,
                Culture = r.Culture,
                Meaning = r.Name,
                JavaScript = r.JavaScript
            }).ToList();

            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }