private void btnGetDatabases_Click(object sender, EventArgs e)
        {
            //Attempt Login
            _user     = textBoxLogin.Text;
            _password = textBoxPassword.Text;
            _url      = textBoxURL.Text;
            _db       = cmbDatabase.Text;

            //write config file
            saveConfig();


            //get dbs from test connection
            try
            {
                _conn = IomFactory.CreateHttpServerConnection(_url, _db, _user, _password);
                string[] databases = _conn.GetDatabases();
                for (int i = 0; i < databases.Length; i++)
                {
                    cmbDatabase.Items.Add(databases[i]);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #2
0
        public ActionResult Index(LoginInfo[] info)
        {
            string message = "";

            if (info != null)
            {
                HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(info[0].網路位址, info[0].資料庫名稱, info[0].帳號, info[0].密碼);
                Item login_result        = cnx.Login();
                if (login_result.isError())
                {
                    message = "登入失敗:" + login_result.getErrorString();
                }
                else
                {
                    message = "登入成功";
                    Session["innovator"] = login_result.getInnovator();

                    string uID = login_result.getInnovator().getUserID();
                    Session["user_id"]   = uID;
                    Session["user_name"] = login_result.getInnovator().getItemById("User", uID).getProperty("keyed_name", "");
                }
                TempData["Result"] = message;

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public static void OneTimeSetUp()
        {
            // do this once-and-for-all when unit testing
            // Logger.EnableConsoleLogging = true;
            Logger.AlwaysIncrementLogNumber = true;
            ArasPermissionGrant.Disable     = true;
            _connectionCount++;

            if (_connectionCount > 1)
            {
                if (Innovator == null)
                {
                    throw new ArasException("ArasTestBase Setup failed.");
                }
                return;
            }

            var loginInfo = LoginInfo.Load();

            if (loginInfo == null)
            {
                throw new ArasException("No user logged in. Cannot run tests against Aras.");
            }

            var slnDir = TestContext.CurrentContext.TestDirectory;

            while (slnDir != null && !Directory.EnumerateFiles(slnDir, "*.sln").Any())
            {
                slnDir = Directory.GetParent(slnDir).FullName;
            }

            if (slnDir == null)
            {
                throw new ArasException(
                          $"Failed to find top/solution directory in parents of {TestContext.CurrentContext.TestDirectory}");
            }

            Console.WriteLine(slnDir);

            var developmentDb = GetDevelopmentDb(slnDir);

            Connection = IomFactory.CreateHttpServerConnection(
                developmentDb.Url, developmentDb.DbName,
                loginInfo.Username, loginInfo.Password);

            Connection.Timeout     = 15000; // need time for AppPool recycle on new DLLs
            Connection.Compression = CompressionType.deflate;

            LoginItem = Connection.Login();

            if (LoginItem.isError())
            {
                throw new ArasException("Aras login failed: " + LoginItem.getErrorString());
            }

            Innovator = LoginItem.getInnovator();
            LogFolder = TestContext.CurrentContext.WorkDirectory;
            ArasExtensions.Innovator     = Innovator;
            ArasExtensions.LogRootFolder = LogFolder;
        }
Beispiel #4
0
        /// <summary>
        /// 自动完成
        /// </summary>
        public static WORKFLOW_PROCESS_PATH AutoCompleteActivityByParam(string id, string tableName, string lineName = "agree")
        {
            string url         = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName      = ConfigurationManager.AppSettings["ArasDB"];
            string accountName = ConfigurationManager.AppSettings["Administrator"];
            string password    = ConfigurationManager.AppSettings["ArasPassword"];

            //使用管理员帐号登陆
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, accountName, password);
            Item login_result         = conn.Login();

            if (!login_result.isError())
            {
                var  inn          = login_result.getInnovator();
                Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "Administrators", tableName);
                if (!activityItem.isError())
                {
                    string activityId           = activityItem.getProperty("activityid");
                    string activityAssignmentId = activityItem.getProperty("activityassignmentid");
                    //任务路线
                    var listActivity = WorkflowProcessPathDA.GetWorkflowProcessPathByActivityId(activityId);
                    WORKFLOW_PROCESS_PATH choicePath = listActivity.Where(x => x.NAME == lineName).FirstOrDefault();
                    //替换符
                    ReplaceChars(choicePath);
                    string errorStr = ActivityDA.CompleteActivity(inn, activityId, activityAssignmentId, choicePath.ID, choicePath.NAME, "", "AutoComplete");
                    if (string.IsNullOrEmpty(errorStr))
                    {
                        return(choicePath);
                    }
                }
            }
            return(null);
        }
Beispiel #5
0
        public string LoginToInnovator(string innovatorUrl, string database, string userName, string password)
        {
            HttpServerConnection serverConnection = null;

            using (new WaitingCursor())
            {
                try
                {
                    serverConnection = IomFactory.CreateHttpServerConnection(innovatorUrl, database, userName, Innovator.ScalcMD5(password));

                    var result = serverConnection.Login();
                    if (result.isError())
                    {
                        serverConnection = null;
                        return(result.getErrorString());
                    }
                }
                catch (Exception ex)
                {
                    serverConnection = null;
                    return(ex.Message);
                }
            }

            innovatorInstance = new Innovator(serverConnection);
            IsLoggedIn        = true;
            return(string.Empty);
        }
Beispiel #6
0
        private void btnGetDatabases_Click(object sender, EventArgs e)
        {
            var oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            cmbDatabase.Items.Clear();

            _url = txtUrl.Text;

            //get dbs from test connection
            try
            {
                _conn = IomFactory.CreateHttpServerConnection(_url, _db, _user, _password);
                string[] databases = _conn.GetDatabases();
                for (int i = 0; i < databases.Length; i++)
                {
                    cmbDatabase.Items.Add(databases[i]);
                }
                Cursor = oldCursor;
            }
            catch (Exception err)
            {
                Cursor = oldCursor;
                MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        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);
        }
Beispiel #8
0
        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!");
            }
        }
Beispiel #9
0
        private void Login_Click(object sender, EventArgs e)
        {
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(URLTextBox.Text, DBsComboBox.Text, LoginTextBox.Text, PasswordTextBox.Text);

            _inn = IomFactory.CreateInnovator(conn);
            this.Close();
        }
Beispiel #10
0
        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>");
            }
        }
Beispiel #11
0
        private void Database_Click(object sender, EventArgs e)
        {
            HttpServerConnection server = IomFactory.CreateHttpServerConnection(URLTextBox.Text);

            string[] dbs = server.GetDatabases();
            DBsComboBox.Items.Clear();
            DBsComboBox.Items.AddRange(dbs);
        }
Beispiel #12
0
        /// <summary>
        /// aras连接
        /// </summary>
        public Innovator ArasConnection(string userName, string password)
        {
            conn = IomFactory.CreateHttpServerConnection(url, DBName, userName, password);
            Item login_result = conn.Login();

            inn = login_result.getInnovator();
            return(inn);
        }
Beispiel #13
0
        public static void TransferToSAP()
        {
            Innovator inn = IomFactory.CreateInnovator(connection);

            Item pendingQueryItem = inn.newItem("GAG_SAPTransferLog", "get");

            pendingQueryItem.setProperty("gag_sap_status", "Pending");
            Item results = pendingQueryItem.apply();

            Item failedQueryItem = inn.newItem("GAG_SAPTransferLog", "get");

            failedQueryItem.setProperty("gag_sap_status", "Failed");
            Item failedresult = failedQueryItem.apply();

            if (results.isEmpty())
            {
                results = failedresult;
            }
            else if (!failedresult.isEmpty())
            {
                results.appendItem(failedresult);
            }

            if (!results.isError())
            {
                foreach (Item logItem in results.Enumerate())
                {
                    DateTime thisDayStart = DateTime.Now;
                    string   nowStart     = thisDayStart.ToString("yyyy-MM-ddTHH:mm:ss");
                    logItem.setAction("edit");
                    logItem.setProperty("gag_start_date", nowStart);

                    string result = CheckSAPConnection();
                    if (result.Equals("Connection Successful"))
                    {
                        string materialID     = logItem.getProperty("gag_material_number");
                        Item   materialPart   = inn.getItemById("Part", materialID);
                        string materialStatus = CheckMaterial(materialPart);
                        if (materialStatus == "Failure")
                        {
                            CreateMaterial(materialPart, logItem);
                        }
                        else
                        {
                            string bomStatus = CheckBOM(materialPart);
                            if (!string.IsNullOrEmpty(bomStatus))
                            {
                                CreateBOM(materialPart, logItem);
                            }
                        }
                    }
                    else
                    {
                        FillLogItem(logItem, $"ERROR!. {result}", "Failed");
                    }
                }
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            connection = IomFactory.CreateHttpServerConnection(ConfigurationManager.AppSettings.Get("url"), ConfigurationManager.AppSettings.Get("database"), ConfigurationManager.AppSettings.Get("user"), ConfigurationManager.AppSettings.Get("password"));
            Item loginResult = connection.Login();

            if (!loginResult.isError())
            {
                TransferToSAP();
            }
        }
Beispiel #15
0
        /// <summary>
        ///  The only constructor for the class.
        /// </summary>
        /// <remarks>
        ///     The constructor itself performs the Aras login and stores the resulting Innovator object in a class
        ///     property.
        /// </remarks>
        /// <param name="url">The URL to the Aras instance.</param>
        /// <param name="db">The database name from which to extract the data model.</param>
        /// <param name="user">The user with which to login to Aras.</param>
        /// <param name="passWord">The password for <paramref name="user"/>.</param>
        /// <exception cref="AuthenticationException">Thrown if no server connection can be established.</exception>
        internal ArasLogin(string url, string db, string user, string passWord)
        {
            ServerConnection = IomFactory.CreateHttpServerConnection(url, db, user, passWord);
            var loginResult = ServerConnection.Login();

            if (loginResult.isError())
            {
                throw new AuthenticationException(loginResult.ToString());
            }
            Innovator = IomFactory.CreateInnovator(ServerConnection);
        }
Beispiel #16
0
        private void tbUrl_Leave(object sender, EventArgs e)
        {
            HttpServerConnection connection = IomFactory.CreateHttpServerConnection(tbUrl.Text);
            var dbs = connection.GetDatabases();

            tbDb.Items.Clear();
            foreach (var db in dbs)
            {
                tbDb.Items.Add(db);
            }
        }
        public static void ClassInitialize(TestContext ctx)
        {
            _connectionCount++;

            if (_connectionCount > 1)
            {
                if (Innovator == null)
                {
                    throw new ArasException("ArasTestBase Setup failed.");
                }
                return;
            }

            var loginInfo = LoginInfo.Load();

            if (loginInfo == null)
            {
                throw new ArasException("No user logged in. Cannot run tests against Aras.");
            }

            var slnDir = ctx.TestRunDirectory;

            while (slnDir != null && !Directory.EnumerateFiles(slnDir, "*.sln").Any())
            {
                slnDir = Directory.GetParent(slnDir).FullName;
            }

            if (slnDir == null)
            {
                throw new ArasException(
                          $"Failed to find top/solution directory in parents of {ctx.TestRunDirectory}");
            }
            var developmentDb = GetDevelopmentDb(slnDir);

            Connection = IomFactory.CreateHttpServerConnection(
                developmentDb.Url, developmentDb.DbName,
                loginInfo.Username, loginInfo.Password);

            Connection.Timeout     = 15000; // need time for AppPool recycle on new DLLs
            Connection.Compression = CompressionType.none;

            LoginItem = Connection.Login();

            if (LoginItem.isError())
            {
                throw new ArasException("Aras login failed: " + LoginItem.getErrorString());
            }

            Innovator = LoginItem.getInnovator();
            LogFolder = ctx.TestDir; // dont use name, shared by many tests
            ArasExtensions.Innovator     = Innovator;
            ArasExtensions.LogRootFolder = LogFolder;
        }
Beispiel #18
0
        private static HttpServerConnection _Login(string usr, string pwd, string url, string db)
        {
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, usr, Innovator.ScalcMD5(pwd));
            Item logResult            = conn.Login();

            if (logResult.isError())
            {
                throw new Exception("Failed to login to Innovator");
            }

            return(conn);
        }
Beispiel #19
0
        private const int DefaultTimeout = 60 * 60 * 1000;         //time in milliseconds

        public IServerConnection Get(string innovatorServerUrl, string database, string userName, string password)
        {
            HttpServerConnection connectionToRemote = IomFactory.CreateHttpServerConnection(
                innovatorServerUrl,
                database,
                userName,
                password
                );

            connectionToRemote.Timeout = DefaultTimeout;

            return(connectionToRemote);
        }
        public HttpServerConnection Connect()
        {
            ServerConnection = IomFactory.CreateHttpServerConnection(
                Config[0].Value, Config[1].Value, Config[2].Value, Config[3].Value
                );
            ServerConnection.Timeout          = 100000;
            ServerConnection.ReadWriteTimeout = 100000;

            Logged?.Invoke(this, new LogEventArgs {
                Message = $"Connected to ARAS with following parameters\r\nServer: {Config[0].Value}\r\nDatabase: {Config[1].Value}\r\nUser: {Config[2].Value}\r\nPass: ", LogEntryType = EventLogEntryType.Information
            });

            return(ServerConnection);
        }
Beispiel #21
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string url  = txtPLMIP.Text;
            string db   = txtPLMDB.Text;
            string user = txtPLMAD.Text;
            string pw   = txtPLMPWD.Text;
            HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(url, db, user, pw);
            Item login_result        = cnx.Login();

            if (!login_result.isError())
            {
                inn = IomFactory.CreateInnovator(cnx);
                MessageBox.Show("Login OK!");
            }
        }
        public Innovator Connect_to_Aras(OfficeConnectorExtensionAddinRibbon MyRibbon)
        {
            string url        = "";
            string db         = "";
            string windowauth = "";
            string user       = "";
            string path       = Environment.GetEnvironmentVariable("Appdata") + "\\OfficeConnector\\config.xml";

            if (System.IO.File.Exists(path))
            {
                XmlReader config = XmlReader.Create(path);
                config.ReadToDescendant("innovator");
                config.MoveToAttribute("innovatorServerName");
                url = config.Value;
                config.MoveToAttribute("innovatorDatabaseName");
                db = config.Value;
                config.MoveToAttribute("innovatorUserName");
                user = config.Value;
                config.MoveToAttribute("isWindowsAuthenticated");
                windowauth = config.Value;
                if (windowauth == "True")
                {
                    WinAuthHttpServerConnection winnconn = IomFactory.CreateWinAuthHttpServerConnection(url, db);
                    Item login_result = winnconn.Login();
                    if (login_result.isError())
                    {
                        System.Windows.Forms.MessageBox.Show("Login failed.  Check configfile for login information ", "Login Failed");
                        return(null);
                    }
                    return(IomFactory.CreateInnovator(winnconn));
                }
                else  //Office connector set up but windowauth not set up so use login information from tab.
                {
                    Common.LoginForm loginform = new LoginForm();
                    loginform.URLTextBox.Text   = url;
                    loginform.DBsComboBox.Text  = db;
                    loginform.LoginTextBox.Text = user;
                    loginform.ShowDialog();
                    return(loginform.Inn);
                }
            }
            else  //Office Connector not set up so use the add-in tab information
            {
                Common.LoginForm loginform = new LoginForm();
                loginform.ShowDialog();
                return(loginform.Inn);
            }
        }
Beispiel #23
0
        public static string CheckSAPConnection()
        {
            Innovator innovator = IomFactory.CreateInnovator(connection);
            string    result;

            Item queryPart = innovator.newItem("GAG_SAPInterfaceSettings", "get");

            queryPart.setProperty("gag_active", "Yes");
            Item queryResult = queryPart.apply();

            if (queryResult.isEmpty())
            {
                result = "No SAP Connection Found. Contact Admin";
                return(result);
            }
            try
            {
                Item sapResult = queryResult.getItemByIndex(0);
                RfcConfigParameters parameters = new RfcConfigParameters
                {
                    [RfcConfigParameters.Name]                  = sapResult.getProperty("gag_name"),
                    [RfcConfigParameters.User]                  = ConfigurationManager.AppSettings.Get("userSAP"),
                    [RfcConfigParameters.Password]              = ConfigurationManager.AppSettings.Get("passwordSAP"),
                    [RfcConfigParameters.PeakConnectionsLimit]  = sapResult.getProperty("gag_peak_connection_limit"),
                    [RfcConfigParameters.ConnectionIdleTimeout] = sapResult.getProperty("gag_connection_idle_time_out"),
                    [RfcConfigParameters.Language]              = sapResult.getProperty("gag_language"),
                    [RfcConfigParameters.AppServerHost]         = sapResult.getProperty("gag_app_server_host"),
                    [RfcConfigParameters.SystemNumber]          = sapResult.getProperty("gag_system_number"),
                    [RfcConfigParameters.Client]                = sapResult.getProperty("gag_client")
                };
                destination = RfcDestinationManager.GetDestination(parameters);
                RfcSessionManager.BeginContext(destination);
                destination.Ping();

                result = "Connection Successful";
                return(result);
            }
            catch (RfcLogonException)
            {
                result = "SAP Log-In Failed";
                return(result);
            }
            catch (RfcCommunicationException)
            {
                result = "SAP Server Connection Error";
                return(result);
            }
        }
Beispiel #24
0
        /// <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;
                    }
                }
            }
        }
        /// <summary>
        /// Logon to Innovator.
        /// </summary>
        /// <param name="userName">string</param>
        /// <param name="userPassword">string</param>
        /// <param name="locale">string</param>
        /// <param name="timeZone">string</param>
        private void _Login(string userName, string userPassword, string locale, string timeZone)
        {
            string url = string.Format(CultureInfo.InvariantCulture, "{0}/server/innovatorserver.aspx", System.Configuration.ConfigurationSettings.AppSettings["url"]);
            string db  = System.Configuration.ConfigurationSettings.AppSettings["db"];

            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, userName, Innovator.ScalcMD5(userPassword));

            SetLocale(conn, locale, timeZone);

            Item logResult = conn.Login();

            if (logResult.isError())
            {
                throw new LogOnException("Failed to logon to Innovator");
            }

            inn = new Innovator(conn);
        }
Beispiel #26
0
        /// <summary>
        /// 获取Admin 登录连接
        /// </summary>
        /// <returns></returns>
        public static Innovator GetAdminInnovator()
        {
            string url         = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName      = ConfigurationManager.AppSettings["ArasDB"];
            string accountName = ConfigurationManager.AppSettings["Administrator"];
            string password    = ConfigurationManager.AppSettings["ArasPassword"];

            //使用管理员帐号登陆
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, accountName, password);
            Item login_result         = conn.Login();

            if (!login_result.isError())
            {
                var inn = login_result.getInnovator();
                return(inn);
            }
            return(null);
        }
        private void loginBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            _conn = IomFactory.CreateHttpServerConnection(textBoxURL.Text, cmbDatabase.Text, textBoxLogin.Text, textBoxPassword.Text);
            Item result = _conn.Login();

            if (result.isError())
            {
                MessageBox.Show(string.Format("Login failed with error: {0}", result.getErrorString()), "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.m_inn = IomFactory.CreateInnovator(_conn);

            btnRunSearch.Enabled = true;
            loginBtn.Enabled     = false;
        }
Beispiel #28
0
 public Boolean PLM_Login(string url, string db, string user, string pw)
 {
     try
     {
         //Debugger.Break();
         HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(url, db, user, pw);
         Item login_result        = cnx.Login();
         if (!login_result.isError())
         {
             CoInnovator = IomFactory.CreateInnovator(cnx);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #29
0
        /// <summary>
        /// Returns an HttpServerConnection for the selected instance
        /// </summary>
        /// <param name="url"></param>
        /// <param name="Db"></param>
        /// <param name="InnUser"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        private HttpServerConnection MyIConnection(string url, string Db, string InnUser, string Password)
        {
            HttpServerConnection connection = IomFactory.CreateHttpServerConnection(url, Db, InnUser, Password);

            Item Login = connection.Login();

            if (!Login.isError())
            {
                isConnected        = true;
                inn                = Login.getInnovator();
                btnExecute.Enabled = true;
            }
            else
            {
                btnExecute.Enabled = false;
            }
            return(connection);
        }
Beispiel #30
0
        public ManageLockForm(string serverNameArg, string databaseNameArg, string loginNameArg, string loginPasswordArg, string methodNameArg, IServiceProvider serviceProvider)
        {
            InitializeComponent();

            serverName    = serverNameArg;
            databaseName  = databaseNameArg;
            loginName     = loginNameArg;
            loginPassword = loginPasswordArg;
            methodName    = methodNameArg;
            util          = new CommandUtilities(serviceProvider);

            HttpServerConnection connection;

            Aras.IOM.Innovator inn;

            connection = IomFactory.CreateHttpServerConnection(serverName, databaseName, loginName, loginPassword);
            Aras.IOM.Item iLogin = connection.Login();
            if (iLogin.isError())
            {
                this.DialogResult = DialogResult.Abort;
                this.Close();
                return;
            }

            inn = new Aras.IOM.Innovator(connection);

            Item iQry = inn.newItem();

            iQry.setType("Method");
            iQry.setProperty("name", methodName);
            iQry.setAction("get");
            iQry = iQry.apply();

            connection.Logout();

            if (iQry.isError())
            {
                MessageBox.Show(iQry.getErrorString(), "Server Returned Error", MessageBoxButtons.OK);
                return;
            }

            methodID = iQry.getID();
            updateLockStatusLabel(iQry);
        }