public ActionResult UpdateData()
        {
            ProductPublishVer ver = null;

            using (var client = new ServiceReference1.Service1Client())
            {
                try
                {
                    //TransactionOptions options=new TransactionOptions();
                    //options.IsolationLevel=IsolationLevel.Serializable;
                    //options.Timeout = new TimeSpan(0, 0, 60);
                    using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required))
                    {
                        ver = client.UpdatePublish(CommonService.CompanyId, 2, Sys.CurrentUser.FullName);
                        #region 菜单和权限
                        if (ver.ProductModuleVerk__BackingField != null)
                        {
                            var menus  = new List <SysMenus>();
                            var limits = new List <SysLimits>();
                            ver.ProductModuleVerk__BackingField.ProductMenuLimitsk__BackingField.Each(o =>
                            {
                                switch (o.Typek__BackingField)
                                {
                                case 1:
                                    menus.Add(new SysMenus()
                                    {
                                        MenuId = o.MenuIdk__BackingField, PMenuId = o.PMenuIdk__BackingField, SortOrder = o.SortOrderk__BackingField, Status = o.Statusk__BackingField, Title = o.Titlek__BackingField, URL = o.Urlk__BackingField, CompanyId = CommonService.CompanyId
                                    });
                                    break;

                                case 3:
                                    limits.Add(new SysLimits()
                                    {
                                        LimitId = o.MenuIdk__BackingField, PLimitId = o.PMenuIdk__BackingField, SortOrder = o.SortOrderk__BackingField, Status = Convert.ToInt16(o.Statusk__BackingField), Title = o.Titlek__BackingField, CompanyId = CommonService.CompanyId
                                    });
                                    break;

                                default:
                                    break;
                                }
                            });
                            if (menus.Any())
                            {
                                var list = SysMenuBLL.FindList(o => o.CompanyId == CommonService.CompanyId);
                                SysMenuBLL.Delete(list);
                                SysMenuBLL.AddRange(menus);
                            }
                            if (limits.Any())
                            {
                                var list = SysLimitsBLL.FindList(o => o.CompanyId == CommonService.CompanyId);
                                SysLimitsBLL.Delete(list);
                                SysLimitsBLL.AddRange(limits);
                            }
                        }
                        #endregion
                        #region 角色
                        if (ver.ProductRoleVerk__BackingField != null)
                        {
                            var roles       = new List <SysRoles>();
                            var customMenus = new List <SysCustomMenus>();
                            ver.ProductRoleVerk__BackingField.ProductRolesk__BackingField.Each(o =>
                            {
                                var role       = new SysRoles();
                                role.CompanyId = CommonService.CompanyId;
                                role.RoleId    = o.RoleIdk__BackingField.GetValueOrDefault();
                                role.Title     = o.Titlek__BackingField;
                                role.LimitsIds = o.Limitidsk__BackingField ?? "";
                                //role.Type = 0;
                                role.Status = true;
                                var cm      = new SysCustomMenus()
                                {
                                    CompanyId = role.CompanyId,
                                    Type      = 2,
                                    ObjId     = role.RoleId,
                                    MenuIds   = string.Join(",", o.ProductRoleDatask__BackingField.Where(i => i.HasSelectedk__BackingField).OrderBy(i => i.SortOrderk__BackingField).Select(i => i.MenuIdk__BackingField))
                                };
                                roles.Add(role);
                                customMenus.Add(cm);
                            });
                            if (roles.Any())
                            {
                                var list = SysRoleBLL.FindList(o => o.CompanyId == CommonService.CompanyId);
                                roles.Each(o =>
                                {
                                    var r = list.FirstOrDefault(i => i.RoleId == o.RoleId);
                                    if (r != null)
                                    {
                                        //o.DeptId = r.DeptId;
                                        if (!r.Memo.IsNullOrEmpty())
                                        {
                                            o.Memo = r.Memo;
                                        }
                                        o.Status = r.Status;
                                    }
                                });
                                SysRoleBLL.RemoveCustomMenus(SysRoleBLL.GetCustomMenus());
                                SysRoleBLL.Delete(list);
                                SysRoleBLL.AddRange(roles);
                                SysRoleBLL.AddCustomMenus(customMenus);
                            }
                        }
                        #endregion
                        #region 字典
                        if (ver.ProductDictionaryVerk__BackingField != null)
                        {
                            var dicts = new List <SysDataDictionary>();
                            ver.ProductDictionaryVerk__BackingField.ProductDictionaryDatask__BackingField.Each(o =>
                            {
                                dicts.Add(new SysDataDictionary()
                                {
                                    Depth  = o.Depthk__BackingField,
                                    DicPSN = o.DicPSNk__BackingField,
                                    DicSN  = o.DicSNk__BackingField,
                                    //HasChild = o.HasChildk__BackingField,
                                    SortOrder = o.SortOrderk__BackingField,
                                    Status    = Convert.ToBoolean(o.Statusk__BackingField),
                                    Title     = o.Titlek__BackingField
                                });
                            });
                            if (dicts.Any())
                            {
                                var list = SysDataDictService.FindList(o => o.CompanyId == CommonService.CompanyId);
                                SysDataDictService.Delete(list);
                                SysDataDictService.AddRange(dicts);
                            }
                        }
                        #endregion
                        #region 初始化数据
                        var sqls = new Dictionary <int, string>();
                        var db   = new Pharos.DBFramework.DBHelper();
                        if (ver.ProductDataVerk__BackingField != null)
                        {
                            ver.ProductDataVerk__BackingField.ProductDataSqlsk__BackingField.OrderBy(o => o.RunSortk__BackingField).Each(o =>
                            {
                                sqls[o.MenuIdk__BackingField] = o.RunSqlk__BackingField;
                            });
                            foreach (var de in sqls)
                            {
                                try
                                {
                                    var sql = de.Value;
                                    if (sql.Contains("@"))
                                    {
                                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"@\b[a-zA-Z0-9]*");
                                        sql = sql.Replace(regex.Match(sql).ToString(), CommonService.CompanyId.ToString());
                                    }
                                    db.ExecuteNonQueryText(sql, null);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception("更新初始化数据失败!MenuId:" + de.Key + ";" + Pharos.Sys.LogEngine.ToInnerException(ex).Message);
                                }
                            }
                            sqls.Clear();
                        }
                        #endregion
                        #region 历史数据处理
                        ver.ProductPublishSqlsk__BackingField.OrderBy(o => o.RunSortk__BackingField).Each(o =>
                        {
                            sqls[o.MenuIdk__BackingField] = o.RunSqlk__BackingField;
                        });
                        foreach (var de in sqls)
                        {
                            try
                            {
                                db.ExecuteNonQueryText(de.Value, null);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("历史数据处理失败!MenuId:" + de.Key + ";" + Pharos.Sys.LogEngine.ToInnerException(ex).Message);
                            }
                        }
                        #endregion
                        tran.Complete();
                    }
                }
                catch (Exception e)
                {
                    new Pharos.Sys.LogEngine().WriteError(e);
                    if (ver != null)
                    {
                        client.AddUpdateLog(ver.PublishIdk__BackingField, CommonService.CompanyId, false, Pharos.Sys.LogEngine.ToInnerException(e).Message, Sys.CurrentUser.FullName);
                    }
                    return(Content(OpResult.Fail().ToJson()));
                }
                client.Close();
                return(Content(OpResult.Success().ToJson()));
            }
        }