private IEnumerable <ObjInfo> GetTreeNodes(string guid) { var res = new List <ObjInfo>(); try { var server = _mFilesVaultService.GetServer(); Log.Info("GetTreeNodes-server Ip:" + server.Ip); var app = MFServerUtility.ConnectToServer(server); Log.Info("GetTreeNodes-vault Guid:" + guid); var vault = app.LogInToVault(guid); var units = MFModelUtil.GetUnits(vault).ToList(); res.AddRange(units); foreach (ObjInfo u in units) { var floors = MFModelUtil.GetFloors(vault, u.ID).ToList(); res.AddRange(floors); foreach (ObjInfo f in floors) { var majors = MFModelUtil.GetDisciplines(vault, f.ID).ToList(); res.AddRange(majors); } } vault.LogOutSilent(); app.Disconnect(); } catch (Exception ex) { Log.Error("GetTreeNodes:" + ex.Message); } return(res); }
private IEnumerable <Qa> GetQaList(string guid, string classAlias, string state) { var res = new List <Qa>(); try { var server = _mFilesVaultService.GetServer(); Log.Info("GetQaList-server Ip:" + server.Ip); var userName = AuthUtility.GetUserName(User); Log.Info("GetQaList-userName:"******"GetQaList-password:"******"GetQaList-vault Guid:" + guid); var vault = app.LogInToVault(guid); var qas = MFModelUtil.GetQaList(vault, classAlias, state).ToList(); Log.Info("GetQaList-qas Count:" + qas.Count); res.AddRange(qas); vault.LogOutSilent(); app.Disconnect(); } catch (Exception ex) { Log.Error("GetQaList:" + ex.Message); } return(res); }
public string GetContractor(string username) { var thevault = _projService.GetContractorVault(); if (thevault == null) { return(string.Empty); } var ret = string.Empty; var guid = thevault.Guid; try { var serv = _vaultServerService.GetServer(); var app = MFServerUtility.ConnectToServer(serv); var vault = app.LogInToVault(guid); var users = vault.UserOperations.GetUserAccounts(); vault.LogOutSilent(); app.Disconnect(); foreach (UserAccount userAccount in users) { if (userAccount.LoginName == username) { ret = guid + serv.Ip; } } } catch (Exception ex) { Log.Error(string.Format("noticescontroller,GetContractor connect error:{0}", username), ex); } return(ret); }
public ActionResult ChangePassword(ChangePasswordViewModel model) { bool hasPassword = true; ViewBag.HasLocalPassword = hasPassword; ViewBag.ReturnUrl = Url.Action("ChangePassword"); if (hasPassword) { if (ModelState.IsValid) { SimpleLog("in post changepassword"); SimpleLog("in post changepassword" + model.OldPassword); SimpleLog("in post changepassword" + model.NewPassword); SimpleLog("in post changepassword" + model.ConfirmPassword); var result = true; try { var userid = User.Identity.GetUserName(); SimpleLog("in post 11 name=" + userid); var pass = DBWorldCache.Get(User.Identity.GetUserId()); SimpleLog("in post 22 pass="******"in post 33" + vs.Ip + vs.Port); // var app = MFServerUtility.ConnectToServer(userid, model.OldPassword, vs.Ip, vs.Port); var app = MFServerUtility.ConnectToServer(vs); SimpleLog("in post 44"); app.LoginAccountOperations.UpdateLoginPassword(userid, model.NewPassword); SimpleLog("in post 55"); } catch (Exception ex) { SimpleLog(ex.Message); result = false; } if (result) { SimpleLog("in post success"); return(RedirectToAction("ChangePassword", new { Message = ManageMessageId.ChangePasswordSuccess })); } else { SimpleLog("in post error"); // AddErrors(result); return(RedirectToAction("ChangePassword", new { Message = ManageMessageId.Error })); } } } // If we got this far, something failed, redisplay form return(View(model)); }
private string FeedbackData(string guid, string userid) {//UgSafetyProductionManagementDepartment,UgSecurityGuard,UgSafetySupervisor,UgQualityInspector var ret = "false,false"; try { var serv = _mFilesVaultService.GetServer(); var app = MFServerUtility.ConnectToServer(serv); var vault = app.LogInToVault(guid); var vaultuserid = -1; var users = vault.UserOperations.GetUserAccounts(); foreach (UserAccount userAccount in users) { if (userAccount.LoginName == userid) { vaultuserid = userAccount.ID; break; } } var UgSafetyProductionManagementDepartment = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemUserGroup, MfilesAliasConfig.UgSafetyProductionManagementDepartment); var UgSecurityGuard = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemUserGroup, MfilesAliasConfig.UgSecurityGuard); var UgSafetySupervisor = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemUserGroup, MfilesAliasConfig.UgSafetySupervisor); var UgQualityInspector = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemUserGroup, MfilesAliasConfig.UgQualityInspector); var safetypermission = IsUserInGroup(vaultuserid, UgSafetyProductionManagementDepartment, vault) || IsUserInGroup(vaultuserid, UgSecurityGuard, vault) || IsUserInGroup(vaultuserid, UgSafetySupervisor, vault); var qualitypermission = IsUserInGroup(vaultuserid, UgQualityInspector, vault); vault.LogOutSilent(); app.Disconnect(); ret = safetypermission + "," + qualitypermission; Log.Info(string.Format("GetFeedbackData,{0},{1},{2}", guid, userid, ret)); } catch (Exception ex) { Log.Info(string.Format("GetFeedbackData,{0},{1},{2}", guid, userid, ex.Message)); } //记录到session string key = guid.Replace("{", "").Replace("}", "") + "_permission"; Session[key] = ret; return(ret); }
//public string Get(string request) //{ // try // { // var jsonSerializer = new JavaScriptSerializer(); // var otask = jsonSerializer.Deserialize<MfTask>(request); // var lists = _tasksService.GetTasksByUser(otask.UserId, otask.VaultGuid); // foreach (var taskse in lists) // { // _tasksService.DeleteTasks(taskse); // } // var paras = jsonSerializer.Serialize(lists); // return paras; // } // catch (Exception ex) // { // Log.Error(string.Format("get error:{0}", request), ex); // } // return ""; //} public string GetAllTasks(string request) { try { var jsonSerializer = new JavaScriptSerializer(); var otask = jsonSerializer.Deserialize <RequestAllTasks>(request); var lists = new List <MfTask>(); var serv = _vaultServerService.GetServer(); Log.Info(string.Format("GetAllTasks,{0},{1},{2},{3}", serv.Ip, serv.LocalIp, serv.Port, otask.Guids.Count)); var app = MFServerUtility.ConnectToServer(otask.UserName, otask.PassWord, serv.LocalIp, serv.Port); // app.Connect(MFAuthType.MFAuthTypeSpecificMFilesUser, otask.UserName, otask.PassWord, "", "ncacn_ip_tcp", serv.LocalIp, serv.ServerPort); foreach (string guid in otask.Guids) { try { var vault = app.LogInToVault(guid); Log.Info(string.Format("GetAllTasks,check {0} ,{1} ", vault.CurrentLoggedInUserID, vault.SessionInfo.UserID)); var pos = vault.Name.LastIndexOf('-'); if (pos < 1) { pos = vault.Name.Length; } var tasktitle = vault.Name.Substring(0, pos) + " "; lists.AddRange(GetTaskApprove(vault, vault.CurrentLoggedInUserID, tasktitle)); lists.AddRange(GetTaskWorkflow(vault, vault.SessionInfo.UserID, tasktitle)); vault.LogOutSilent(); } catch (Exception ex) { Log.Error(string.Format("GetAllTasks vault:{0},{1}", guid, ex.Message.Substring(0, 90))); } } app.Disconnect(); Log.Info(string.Format("GetAllTasks,{0} tasks", lists.Count)); var paras = jsonSerializer.Serialize(lists); return(paras); } catch (Exception ex) { Log.Error(string.Format("GetAllTasks error:{0}", request), ex); } return(""); }
private void buttoncreateprojects_Click(object sender, EventArgs e) { var cr = new CreateRes(); var vault = new MFilesVault(); CreateVaultForAllBackup(vault, new VaultTemplate(), null, new MFVaultService()); cr.Vault = vault; try { var server = vault.Server; var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort); var mVault = app.LogInToVault(vault.Guid); var views = mVault.ViewOperations.GetViews(); IList <global::AecCloud.Core.Domain.User> users = GetAllUsers(); List <Company> companies = GetAllCompany(); var proj = new Project(); CreateHeadquatersStaff(mVault, users, companies, proj); // UserAndGroupProcessing(mVault, proj.CompanyId);//need modification,to be continued//deprecated if (proj.Company.Code == "0001A210000000002ORS") //0001A210000000002ORS,中建八局第二建设有限公司, { } else //二级单位 { SecondLevelUserAndGroupProcessing(mVault, users, companies, proj); } // SetVicePresident(mVault, proj, new UserService( ), new MfUserGroupService() ); } catch (Exception ex) { var err = " private static CreateRes CreateProject 创建库中vaultapp error:" + ex.Message; // Log.Error(err); throw; } }
public string GetProjects(string username) { try { var jsonSerializer = new JavaScriptSerializer(); var lists = GetProjects4User(username); var clients = new List <MfilesClientConfig>(); var app = MFServerUtility.ConnectToServer(_vaultServerService.GetServer()); foreach (ProjectDto projectDto in lists) { Vault vault; try { vault = app.LogInToVault(projectDto.Vault.Guid); } catch (Exception ex) { continue; } vault.LogOutSilent(); clients.Add(new MfilesClientConfig { Guid = projectDto.Vault.Guid, Name = projectDto.Name, Host = projectDto.Vault.Server.Ip }); } app.Disconnect(); var paras = jsonSerializer.Serialize(clients); return(paras); } catch (Exception ex) { Log.Error(string.Format("noticescontroller,GetProjects error:{0}", username), ex); } return(""); }
public ActionResult WorkFlow(string vaultGuid, string classAlias, string id, string viewPort) { try { var serv = _mFilesVaultService.GetServer(); var app = MFServerUtility.ConnectToServer(serv); if (String.IsNullOrEmpty(classAlias)) { classAlias = "ClassSecureNotice1"; } var guidstring = vaultGuid; if (!guidstring.StartsWith("{")) { guidstring = "{" + guidstring; } if (!guidstring.EndsWith("}")) { guidstring += "}"; } var vault = app.LogInToVault(guidstring); var workflowClassId = vault.ClassOperations.GetObjectClassIDByAlias(classAlias); var workflowClass = vault.ClassOperations.GetObjectClass(workflowClassId); var workflowObjType = workflowClass.ObjectType; int?template = GetTemplate(vault, workflowClassId); var objPart = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemObjectType, MfilesAliasConfig.ObjPart); var propIfcId = vault.GetMetadataStructureItemIDByAlias(MFMetadataStructureItem.MFMetadataStructureItemPropertyDef, MfilesAliasConfig.PropIfcId); var objPartType = vault.ObjectTypeOperations.GetObjectType(objPart); var objPartsDef = objPartType.DefaultPropertyDef; var parts = new List <int>(); var pp = id.Split(new[] { ',' }); foreach (var p in pp) { var partId = GetPartId(vault, objPart, propIfcId, p); if (partId != null) { parts.Add(partId.Value); } } int pIdViewPort = MfAlias.GetPropDef(vault, "PropViewPortParams"); //模型视口参数 vault.LogOutSilent(); app.Disconnect(); if (parts.Count == 0) { return(Json(new Dictionary <string, string> { { "status", "500" }, { "message", string.Format("在vault-{0}中没有找到ifcguid={1}的构件", vaultGuid, id) } }, JsonRequestBehavior.AllowGet)); } var propValues = new Dictionary <string, string>(); propValues.Add(objPartsDef.ToString(), String.Join(",", parts)); propValues.Add(pIdViewPort.ToString(), viewPort);//test var url = _mfvaultService.CreateObjectUrl(vaultGuid, workflowObjType, workflowClassId, propValues, template); return(Json("OK-" + url, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(string.Format("{0},{1},{2}", vaultGuid, id, ex.Message), ex); return(Json(new Dictionary <string, string> { { "status", "500" }, { "message", string.Format("{0},{1},{2}", vaultGuid, id, ex.Message) } }, JsonRequestBehavior.AllowGet)); } //var retjs = new Dictionary<string, string> //{ // {"status", "500"}, // {"message", string.Format("在vault-{0}中没有找到ifcguid={1}的构件", vaultGuid, id)} //}; //return Json(retjs, JsonRequestBehavior.AllowGet); }
public ActionResult Index() { //先获取用户ID,一边后期在存储默认项目时区分不同用户使用 try { var profile = GetUserProfile(_userManager); ViewBag.userId = profile.Id; var projs = GetProjects4CurrentUser(); var currentuserid = long.Parse(User.Identity.GetUserId()); // var loginName = _userService.GetUserById(currentuserid).GetAccountName(); // var userId =Authentication.User.Identity.GetUserId<int>(); var user = _userService.GetUserById(currentuserid); // var password = DBWorldCache.Get(user.Id.ToString()); foreach (ProjectDto projectDto in projs) { // Log.Info(string.Format("project center---{0},{1},{2}", // currentuserid, loginName, projectDto.Vault.Name)); try { //Log.Info(string.Format("before connect:{0},{1},{2},{3},{4},{5},{6},{7},{8}", loginName, password, // projectDto.Vault.Server.Ip, // projectDto.Vault.Server.Port, user.Id, user.FullName, user.UserName, user.Password, // user.PasswordHash)); var app = MFServerUtility.ConnectToServer(_mfvaultService.GetServer(projectDto.VaultId)); ; var vault = app.LogInToVault(projectDto.Vault.Guid); var viewid = -1; try { var views = vault.ViewOperations.GetViews(); foreach (View view in views) { if (view.Name == "主目录") { viewid = view.ID; break; } } if (viewid < 0) { foreach (View view in views) { if (view.Name == "根目录") { viewid = view.ID; break; } } } projectDto.Url = vault.ViewOperations.GetMFilesURLForView(viewid); } catch (Exception ex) { Log.Info("search time project :" + projectDto.Name, ex); } vault.LogOutSilent(); app.Disconnect(); } catch (Exception) { projectDto.NotDisplay = true; Log.Info("查询有权限的项目:" + "测试库已清除"); continue; } } var bim = new BIMModel() { ProjectDto = projs.Where(c => c.NotDisplay != true).ToList() }; // Log.Info(string.Format("project center:all={0},display={1}", projs.Count(), bim.ProjectDto.Count)); return(View(bim)); } catch (Exception ex) { return(View(new BIMModel { ProjectDto = new List <ProjectDto>() })); } }
public async Task <ActionResult> LogOn(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // 这不会计入到为执行帐户锁定而统计的登录失败次数中 // 若要在多次输入错误密码的情况下触发帐户锁定,请更改为 shouldLockout: true var userRes = await Task.Run(() => AuthUtility.Login(model.UsernameOrEmail, model.Password, model.IsDomainUser, _userManager, _vaultserverService, _mfuserService, _userService)); if (userRes.User != null) { var user = userRes.User; await _signInManager.SignInAsync(user, model.RememberMe, false); // Log.InfoFormat("登录账户:{0}, 公司:{1},部门:{2}", user.UserName, user.Company.Name, user.Department.Name); DBWorldCache.Add(user.Id.ToString(), model.Password); //check whether current user can connect contractor vault. try { //分包商菜单处理,使用缓存 var thevault = _vaultRepository.Table.FirstOrDefault(c => c.CloudId == 3); var app = MFServerUtility.ConnetToMfApp(user, model.Password, thevault.Server); var vault = app.LogInToVault(thevault.Guid); DBWorldCache.Add(user.Id.ToString() + "canManageContractor", "true"); // SimpleLog(user.FullName + "can view contractors,id=" + user.Id); } catch (Exception) { } try { var vs = _vaultserverService.GetServer(); var mfapp = MFServerUtility.ConnectToServer(vs); var vaults = mfapp.GetOnlineVaults(); foreach (VaultOnServer vaultOnServer in vaults) { // SimpleLog(vaultOnServer.Name + " task check!"); Vault vault; try { vault = vaultOnServer.LogIn(); } catch (Exception) { SimpleLog(string.Format("Info: vault:{0},{1}", vaultOnServer.Name, "no right")); continue; } try { var havetask = CheckTaskInOneVault(vault, user.Id); if (havetask) { DBWorldCache.Add(user.Id.ToString() + "havetask", havetask.ToString()); // SimpleLog(vault.Name + " havetask !"); break; } // SimpleLog(vault.Name + " have no task !"); } catch (Exception ex) { SimpleLog("havetask check error:" + ex.Message); } } foreach (VaultOnServer vaultOnServer in vaults) { // SimpleLog(vaultOnServer.Name + " notice check!"); Vault vault; try { vault = vaultOnServer.LogIn(); } catch (Exception) { SimpleLog(string.Format("Info: vault:{0},{1}", vaultOnServer.Name, "no right")); continue; } try { var havenotice = CheckNoticeInOneVault(vault, user.Id); if (havenotice) { DBWorldCache.Add(user.Id.ToString() + "havenotice", havenotice.ToString()); SimpleLog(vault.Name + " havenotice !"); break; } // SimpleLog(vault.Name + " have no notice !"); } catch (Exception ex) { SimpleLog("havenotice check error:" + ex.Message); } } } catch (Exception ex) { SimpleLog("check whether current user can connect contractor vault." + ex.Message); } return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", userRes.Error); } return(View(model)); }