protected void Submit_Click(object sender, EventArgs e) { string myTitle = PRTitle.Text; string myDescription = PRDesc.Text; string mySteps2Rep = PRStepsRepeat.Text; if (myTitle == "" || myDescription == "") { Page.ClientScript.RegisterClientScriptBlock(GetType(), "MyAlert", "<script>alert('Please fill in required fields of PR Title and PR Description!!!')</script>"); } else { string url = url_text.Text; string db = db_text.Text; string user = user_text.Text; string password = password_text.Text; HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, user, password); Item login_result = conn.Login(); if (login_result.isError()) { throw new Exception("Login failed:" + login_result.getErrorDetail()); } Innovator inn = IomFactory.CreateInnovator(conn); Item myPR = inn.newItem("PR", "add"); myPR.setProperty("title", myTitle); myPR.setProperty("description", myDescription); myPR.setProperty("events", mySteps2Rep); myPR.apply(); conn.Logout(); Page.ClientScript.RegisterClientScriptBlock(GetType(), "MyAlert", "<script>alert('Your PR was created successfully!!!')</script>"); } }
public override void Connect(IReadOnlyCollection <Component> instanceComponents) { Logger.Instance.Log(LogLevel.Info, "\nConfiguring components ({0}, {1}, {2}, {3}) to work with component({4}):\n", ESAgentComponentId, ESIndexComponentId, ESZookeeperComponentId, ESFileProcessorComponentId, DatabaseComponentId); ESAgentComponent esAgent = instanceComponents.Single(c => c.Id == ESAgentComponentId) as ESAgentComponent; ESIndexComponent esIndex = instanceComponents.Single(c => c.Id == ESIndexComponentId) as ESIndexComponent; ESZooKeeperComponent esZooKeeper = instanceComponents.Single(c => c.Id == ESZookeeperComponentId) as ESZooKeeperComponent; ESFileProcessorComponent esFileProcessor = instanceComponents.Single(c => c.Id == ESFileProcessorComponentId) as ESFileProcessorComponent; DatabaseComponent databaseComponent = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent; DropSolrIndex(esIndex); string serviceNameXPath = "/configuration/ServiceName"; esFileProcessor.ServiceName = FileSystemFactory.GetFileSystem(esFileProcessor.ServerName).XmlHelper.XmlPeek(esFileProcessor.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esFileProcessor.ServerName, esFileProcessor.ServiceName); esAgent.ServiceName = FileSystemFactory.GetFileSystem(esAgent.ServerName).XmlHelper.XmlPeek(esAgent.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esAgent.ServerName, esAgent.ServiceName); esIndex.ServiceName = FileSystemFactory.GetFileSystem(esIndex.ServerName).XmlHelper.XmlPeek(esIndex.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esIndex.ServerName, esIndex.ServiceName); esZooKeeper.ServiceName = FileSystemFactory.GetFileSystem(esZooKeeper.ServerName).XmlHelper.XmlPeek(esZooKeeper.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esZooKeeper.ServerName, esZooKeeper.ServiceName); //Wait Until services are stopped for 30 seconds Thread.Sleep(30000); HttpServerConnection connection = IomFactory.CreateHttpServerConnection(databaseComponent.InnovatorUrl, databaseComponent.DatabaseName, databaseComponent.LoginOfRootInnovatorUser, databaseComponent.PasswordOfRootInnovatorUser.Value); try { connection.Login(); Innovator innovator = new Innovator(connection); EditVariable(innovator, "ES_SolrUrl", esIndex.ESAIClusterUrl); EditVariable(innovator, "ES_AIClusterUrl", esIndex.ESAIClusterUrl); EditCryptoPwd(innovator, esAgent); } finally { connection.Logout(); } UpdateESZooKeeperServiceConfig(esZooKeeper, databaseComponent); WindowsServiceHelper.StartService(esZooKeeper.ServerName, esZooKeeper.ServiceName); UpdateESIndexServiceConfig(esIndex, databaseComponent); WindowsServiceHelper.StartService(esIndex.ServerName, esIndex.ServiceName); UpdateESAgentServiceConfig(esAgent, databaseComponent); WindowsServiceHelper.StartService(esAgent.ServerName, esAgent.ServiceName); UpdateESFileProcessorServiceConfig(esFileProcessor, databaseComponent); WindowsServiceHelper.StartService(esFileProcessor.ServerName, esFileProcessor.ServiceName); ReloadSolrCollection(esIndex); }
string CreateFileItem(string URL, string database, string username, string password) { string filePath = "C:\\temp\\TesTDocument1.doc"; HttpServerConnection conn = IomFactory.CreateHttpServerConnection(URL, database, username, password); Item login_result = conn.Login(); if (login_result.isError()) { throw new Exception("Login failed"); } Innovator inn = IomFactory.CreateInnovator(conn); Item fileItem = inn.newItem("File", "add"); fileItem.setProperty("filename", new System.IO.FileInfo(filePath).Name); fileItem.attachPhysicalFile(filePath); Item result = fileItem.apply(); conn.Logout(); if (result.isError()) { return(result.getErrorString()); } else { return("Success!"); } }
public void Logout() { this.password = ""; connection.Logout(); innovator = null; connection = null; }
private void btn_disconnection_Click_1(object sender, EventArgs e) { mc_conn.Logout(); mc_conn = null; mc_innovator = null; SettingConnectionButton(false); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { SaveConfig(); if (_conn != null) { _conn.Logout(); } }
/// <summary> /// 登陆获取用户信息 /// </summary> /// <param name="loginName"></param> public static void LogIn(string loginName, UserInfo user) { string url = ConfigurationManager.AppSettings["ArasUrl"]; string dbName = ConfigurationManager.AppSettings["ArasDB"]; //获取用户信息 USER userObJ = UserDA.GetUserByLoginName(loginName); if (userObJ != null) { user.UserId = userObJ.ID; user.UserName = userObJ.KEYED_NAME; user.LoginName = userObJ.LOGIN_NAME; user.Password = userObJ.PASSWORD; user.b_JobNumber = userObJ.B_JOBNUMBER; user.Email = userObJ.EMAIL; HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, user.LoginName, user.Password); Item login_result = conn.Login(); if (login_result.isError()) { if (conn != null) { conn.Logout(); } } else { var inn = login_result.getInnovator(); if (inn != null) { //获取当前角色身份 List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.UserId); user.Roles = listRoles; if ((user.AgentAuth == null && user.AgentCreateTime == null) || (user.AgentCreateTime != null)) { List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(user.UserName); if (AgentSetList.Count > 0) { AgentSetBll.GetAgentRoles(inn, user, AgentSetList); } } user.inn = inn; } } } }
//reset private void connLogout() { //make sure there is a connection object (this event is called when form is first displayed) if (_conn != null) { _conn.Logout(); loginBtn.Enabled = true; syncCheckoutBtn.Enabled = false; cancelBtn.Enabled = false; asyncCheckoutBtn.Enabled = false; sfLbl.Visible = false; setupSearch(false); btnRunSearch.Enabled = false; } }
private void ThisAddIn_Startup(object sender, EventArgs e) { try { string passwordHash = Innovator.ScalcMD5(password); serverConnection = IomFactory.CreateHttpServerConnection(innovatorServerUrl, database, userName, passwordHash); var autorizationItem = (serverConnection as HttpServerConnection).Login(); if (autorizationItem.isError()) { serverConnection.Logout(); throw new Exception(autorizationItem.getErrorString()); } Innovator = autorizationItem.getInnovator(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void checkConnectionClick(object sender, RoutedEventArgs e) { string error; HttpServerConnection serverConnection = null; try { serverConnection = IomFactory.CreateHttpServerConnection( Server, Database, UserName, Password); Innovator innovator = new Innovator(serverConnection); Item checkConnectionItem = innovator.applyAML("<AML><Item type=\"ItemType\" action=\"get\"><name>ItemType</name></Item></AML>"); error = checkConnectionItem.isError() ? checkConnectionItem.getErrorDetail() : null; } catch (Exception exception) { error = exception.ToString(); } finally { if (serverConnection != null) { serverConnection.Logout(); } } if (string.IsNullOrEmpty(error)) { MessageBox.Show("Works fine", "OK", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(error, "An error occured", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static bool LogIn(string pUrl, string pDBName, string pUserName, string pPassword, ref string strError) { try { connection = IomFactory.CreateHttpServerConnection(pUrl, pDBName, pUserName, pPassword); Item result = connection.Login(); if (result.isError()) { if (connection != null) { connection.Logout(); } string str = result.getErrorString(); int startIndex = (str.IndexOf(":") + 1); if (startIndex > 0) { str = str.Substring(startIndex); } if (str.Contains("Authentication")) { str = "Invalid user or password"; } strError = str; return(false); } else { inn = result.getInnovator(); return(true); } } catch (Exception ex) { strError = ex.Message; return(false); } }
private void Main_FormClosed(object sender, FormClosedEventArgs e) { conn.Logout(); }
private void ThisAddIn_Shutdown(object sender, EventArgs e) { serverConnection.Logout(); }
/// <summary> /// 登入(Login) /// </summary> /// <param name="pUrl">URL</param> /// <param name="pDBName">DBName</param> /// <param name="pUserName">UserName</param> /// <param name="pPassword">Password</param> /// <returns></returns> public ActionResult LogIn() { //判断当前系统语言 string language = Request.Headers["Accept-Language"].ToString(); language = language.Split(',')[0].ToString(); if (language.IndexOf("en") >= 0) { language = "English"; } else { language = "Chinese"; } string url = ConfigurationManager.AppSettings["ArasUrl"]; string dbName = ConfigurationManager.AppSettings["ArasDB"]; string username = Request.Form["Username"]; string password = Request.Form["Password"]; string ChoicePath = Request.Form["ChoicePath"]; string str = ""; try { //string DomainKey = "admin"; //string ForceSha = "0"; //string passwordStr = CommonMethod.md5string16(DomainKey, ForceSha == "1" ? true : false) + CommonMethod.md5string16(username.ToLower(), ForceSha == "1" ? true : false) + username.ToLower() + DomainKey; //HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, username, password); //Item login_result = conn.Login(); //if (login_result.isError()) //{ //} //strPassword = md5string16(DomainKey, IIf(ForceSha = "1", True, False)) + md5string16(strUserName.ToLower(), IIf(ForceSha = "1", True, False)) + strUserName.ToLower() + DomainKey 参考代码 UserInfo user = new UserInfo(); string errorMsg = ""; //if (username == "admin") //{ // HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, username, password); // Item login_result = conn.Login(); // if (login_result.isError()) // { // if (conn != null) { conn.Logout(); } // str = login_result.getErrorString(); // int startIndex = (str.IndexOf(":") + 1); // if (startIndex > 0) { str = str.Substring(startIndex); } // if (str.Contains("Authentication")) { str = "Invalid user or password"; } // } // else // { // errorMsg = "AD Login OK"; // } //} //else //{ // errorMsg = LoginAD(username, password); //} errorMsg = "AD Login OK"; if (errorMsg == "AD Login OK") { //获取用户信息 USER userObJ = UserDA.GetUserByLoginName(username); // 创建登录凭证 user.UserId = userObJ.ID; user.UserName = userObJ.KEYED_NAME; user.LoginName = userObJ.LOGIN_NAME; user.Password = userObJ.PASSWORD; user.HTTP_USER_AGENT = Request.UserAgent; user.UserIp = Request.UserHostAddress; user.b_JobNumber = userObJ.B_JOBNUMBER; user.Email = userObJ.EMAIL; user.language = language; user.b_AffiliatedCompany = userObJ.B_AFFILIATEDCOMPANY; //获取AD域中的信息 CommonMethod.GetAdInfoByUser(user, "bordrin.com"); user.ExpireDate = DateTime.Now.AddDays(1); //Innovator.ScalcMD5(user.Password) HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, user.LoginName, user.Password); Item login_result = conn.Login(); if (login_result.isError()) { if (conn != null) { conn.Logout(); } str = login_result.getErrorString(); int startIndex = (str.IndexOf(":") + 1); if (startIndex > 0) { str = str.Substring(startIndex); } if (str.Contains("Authentication")) { str = "Invalid user or password"; } } else { var inn = login_result.getInnovator(); //string token = Guid.NewGuid().ToString("N").ToUpper(); //获取当前角色身份 List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.UserId); user.Roles = listRoles; //获取当前权限信息 if (user.MemuAuth == null) { user.MemuAuth = new List <string>(); for (int j = 0; j < listRoles.Count; j++) { string id = listRoles[j]; //根据Id获取权限列表 Item ItemTypes = ItemTypeDA.GetMenuAuthByIdentity(inn, id); if (ItemTypes.getItemCount() > 0) { for (int i = 0; i < ItemTypes.getItemCount(); i++) { Item itemobj = ItemTypes.getItemByIndex(i); string itemName = itemobj.getProperty("name"); if (user.MemuAuth.IndexOf(itemName) < 0) { user.MemuAuth.Add(itemName); } } } } } user.inn = inn; //获取委托的权限数据 DateTime currentTime = DateTime.Now.AddMinutes(-10); if ((user.AgentAuth == null && user.AgentCreateTime == null) || (user.AgentCreateTime != null && currentTime > user.AgentCreateTime)) { List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(user.UserName); if (AgentSetList.Count > 0) { AgentSetBll.GetAgentRoles(inn, user, AgentSetList); } } UserBll.SaveUserInfoToCache(user); // 设置用户 cookie HttpCookie cookie = new HttpCookie("Passport.Token"); cookie.Value = user.LoginName; cookie.Expires = DateTime.Now.AddHours(8); cookie.Secure = FormsAuthentication.RequireSSL; Response.Cookies.Add(cookie); if (ChoicePath == "0") { return(Redirect("/Portal/Index")); } else { return(Redirect("/Home/Index")); } } } else { str = "Invalid user or password"; } } catch (Exception ex) { str = "Invalid user or password"; } return(RedirectToAction("Index", "Login", new { errorStr = str, isAdLogin = false })); }
public static void CreateMaterial(Item materialPart, Item logItem) { IRfcFunction material = destination.Repository.CreateFunction("BAPI_MATERIAL_SAVEDATA"); IRfcStructure headDataStructure = material.GetStructure("HEADDATA"); string sapMaterialType = materialPart.getProperty("gag_sap_material_type"); string materialNumber = materialPart.getProperty("item_number"); string revision = materialPart.getProperty("major_rev"); string materialNum = materialNumber + "-" + revision; string standardDesignation = materialPart.getProperty("gag_standard_designation"); string dimensionStandard = materialPart.getProperty("gag_dimension_standard"); string basicMaterial = materialPart.getProperty("gag_material"); string gagtheoreticalWeight = materialPart.getProperty("gag_theoretical_weight"); string gagmeasuredWeight = materialPart.getProperty("gag_measured_weight"); decimal theoreticalWeight; if (string.IsNullOrEmpty(gagtheoreticalWeight)) { theoreticalWeight = 0; } else { theoreticalWeight = decimal.Parse(gagtheoreticalWeight); } decimal measuredWeight; if (string.IsNullOrEmpty(gagmeasuredWeight)) { measuredWeight = 0; } else { measuredWeight = decimal.Parse(gagmeasuredWeight); } string sapUOM = ""; string sapUOMX = ""; string arasUOM = materialPart.getProperty("gag_sap_unit_of_measure"); if (arasUOM == "Pc") { sapUOM = "ST"; sapUOMX = "PCE"; } else if (arasUOM == "kg") { sapUOM = "KG"; sapUOMX = "KGM"; } else if (arasUOM == "m2") { sapUOM = "M2"; sapUOMX = "MTK"; } else if (arasUOM == "lm") { sapUOM = "LM"; sapUOMX = "MTR"; } else if (arasUOM == "m") { sapUOM = "M"; sapUOMX = "MTR"; } decimal weight = (measuredWeight != 0) ? measuredWeight : theoreticalWeight; headDataStructure.SetValue("material", materialNum); headDataStructure.SetValue("ind_sector", "M"); headDataStructure.SetValue("matl_type", sapMaterialType); headDataStructure = material.GetStructure("CLIENTDATA"); headDataStructure.SetValue("base_uom", sapUOM); headDataStructure.SetValue("base_uom_iso", sapUOMX); headDataStructure.SetValue("NET_WEIGHT", weight); headDataStructure.SetValue("UNIT_OF_WT_ISO", "KGM"); headDataStructure.SetValue("UNIT_OF_WT", "KG"); headDataStructure.SetValue("CAD_ID", "X"); headDataStructure.SetValue("STD_DESCR", standardDesignation); headDataStructure.SetValue("SIZE_DIM", dimensionStandard); headDataStructure.SetValue("BASIC_MATL", basicMaterial); headDataStructure = material.GetStructure("CLIENTDATAX"); headDataStructure.SetValue("base_uom", "X"); headDataStructure.SetValue("base_uom_iso", "X"); headDataStructure.SetValue("NET_WEIGHT", "X"); headDataStructure.SetValue("UNIT_OF_WT_ISO", "X"); headDataStructure.SetValue("UNIT_OF_WT", "X"); headDataStructure.SetValue("CAD_ID", "X"); headDataStructure.SetValue("STD_DESCR", "X"); headDataStructure.SetValue("SIZE_DIM", "X"); headDataStructure.SetValue("BASIC_MATL", "X"); IRfcTable materialdescription = material.GetTable("MATERIALDESCRIPTION"); string englishDescription = materialPart.getProperty("name"); string germanDescription = materialPart.getProperty("gag_name_ge"); string italianDescription = materialPart.getProperty("gag_name_it"); string frenchDescription = materialPart.getProperty("gag_name_fr"); string portugueseDescription = materialPart.getProperty("gag_name_pt"); string turkishDescription = materialPart.getProperty("gag_name_tr"); string spanishDescription = materialPart.getProperty("gag_name_es"); IDictionary <string, string> descriptions = new Dictionary <string, string> { { "EN", englishDescription }, { "DE", germanDescription }, { "IT", italianDescription }, { "FR", frenchDescription }, { "S", spanishDescription }, { "PT", portugueseDescription }, { "TR", turkishDescription }, }; foreach (KeyValuePair <string, string> description in descriptions) { if (!string.IsNullOrEmpty(description.Value)) { materialdescription.Append(); materialdescription.SetValue("LANGU", description.Key); materialdescription.SetValue("MATL_DESC", description.Value); } } material.Invoke(destination); IRfcStructure returnMessage = material.GetStructure("RETURN"); string messageOutput = returnMessage.GetString("MESSAGE"); IRfcFunction materialCommitFunction = destination.Repository.CreateFunction("BAPI_TRANSACTION_COMMIT"); materialCommitFunction.Invoke(destination); if (messageOutput.Contains("created")) { CreateBOM(materialPart, logItem); } else { FillLogItem(logItem, $"Material NOT Created. {messageOutput}", "Failed"); } connection.Logout(); }
private void btnLogin_Click(object sender, EventArgs e) { var oldCursor = Cursor; Cursor = Cursors.WaitCursor; _user = txtUser.Text; _password = txtPassword.Text; _url = txtUrl.Text; _db = cmbDatabase.Text; //write config file SaveConfig(); _conn = IomFactory.CreateHttpServerConnection(_url, _db, _user, _password); Item login_result = _conn.Login(); Cursor = oldCursor; if (login_result.isError()) { //if already connected the logout of previous connection if (_conn != null) { _conn.Logout(); } //get details of error string error_str = login_result.getErrorString(); //Interpret message string - remove header text before : symbol int pos = error_str.IndexOf(':') + 1; if (pos > 0) { error_str = error_str.Substring(pos); } //If error contains keyword clean up message text if (error_str.Contains("Authentication")) { error_str = "Invalid user or password"; } if (error_str.Contains("Database")) { error_str = "Database not available"; } MessageBox.Show("Login failed!\r\n\r\n" + error_str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } lblFileName.Enabled = true; btnLogin.Enabled = false; btnFileOpen.Enabled = true; btnLoad.Enabled = true; txtUrl.Enabled = false; txtUser.Enabled = false; txtPassword.Enabled = false; cmbDatabase.Enabled = false; btnGetDatabases.Enabled = false; //Get innovator object _inn = IomFactory.CreateInnovator(_conn); }