Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
 private void btn_disconnection_Click_1(object sender, EventArgs e)
 {
     mc_conn.Logout();
     mc_conn      = null;
     mc_innovator = null;
     SettingConnectionButton(false);
 }
Ejemplo n.º 4
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"));
        }
Ejemplo n.º 5
0
        public void M5SetupTest()
        {
            var clientPubKey = FixedSaltGenerator.ExpectedClientPubKey;
            var clientProof  = FixedSaltGenerator.ExpectedClientProof;
            var inputData    =
                "059ac2e1aa3fef6c4bc067cd9d26a05b53fa6ad29f953af80c90968757a18fcb270118987a5c26e50f2f8e274750584929d5d5a176a62af5ef0d4002ed6333ee75b0f75d0ee4dbef345f6ae15345cfdcb97e3300d18bf8f827701f6dfcc6cc213dff5ae1cffa03235853df30d8eb6ceec068dc64e9ef8049ce3d9396bbd32c7b2e329005023cf06ed8a60e3e51491b7f7193a807f1f244369a5ee9fd060105";
            var expectedTlvHexReponse =
                "0601060587b0e4a7aa382866e824db4159cc0ecd24900136be360fd6ae64481bf799b1ecc918ecb887285a8dcd5b6f90aa410253451fd1bc638cae716cbab166f763108633555a6bfa311662986ea2d1eb83b76d195724b9bbddf7902dfd3a16e1bbd5bb8e5a5a6e3a56e8eec21c3f06ed2cce21ea17426407d0a1b35c9d692f5a5ee15ecb7ac662ade25ab7";

            var tlv = TlvParser.Parse(Automatica.Core.Driver.Utility.Utils.StringToByteArray(inputData));

            var fixedSrpGenerator = new FixedSaltGenerator();

            var session = new ConnectionSession
            {
                Salt            = fixedSrpGenerator.GenerateSalt(16),
                Verifier        = FixedSaltGenerator.ExpectedVerifier,
                ServerEphemeral = fixedSrpGenerator.GenerateServerEphemeral(FixedSaltGenerator.ExpectedVerifier)
            };

            session.ServerSession = fixedSrpGenerator.DeriveServerSession(session.ServerEphemeral.Secret, clientPubKey, SrpInteger.FromByteArray(session.Salt).ToHex(), "Pair-Setup", session.Verifier, clientProof);

            var setupController = new PairSetupController(NullLogger.Instance, "031-45-154")
            {
                SrpGenerator = fixedSrpGenerator, KeyGenerator = new FixedEd25519KeyGenerator()
            };

            var ret = setupController.Post(tlv, session);

            var expectedTlvResponse =
                TlvParser.Parse(Automatica.Core.Driver.Utility.Utils.StringToByteArray(expectedTlvHexReponse));

            var decryptedPayload = TlvParser.Parse(Automatica.Core.Driver.Utility.Utils.StringToByteArray(
                                                       "011146433a32323a33443a45333a43453a4632032083e6d70e7064effd0c6df6d19451b1ded53f7e2d0dd86e33d4aa1993f5e9cded0a402ac3063b1d193c4d365c546019c51cac8299a23a99c9f8eb2348c46af24b185a53f1f75a92d57193bdeb4dfbc47ccadccc4f9f4e3dc8191eef364d15cd921207"));
            var raw = setupController.HandlePairSetupM5Raw(session, out _);

            Assert.Equal(decryptedPayload.GetType(Constants.Identifier), raw.GetType(Constants.Identifier));
            Assert.Equal(decryptedPayload.GetType(Constants.PublicKey), raw.GetType(Constants.PublicKey));
            Assert.Equal(decryptedPayload.GetType(Constants.Signature), raw.GetType(Constants.Signature));

            var expectedEncryptedData =
                Automatica.Core.Driver.Utility.Utils.ByteArrayToString(expectedTlvResponse.GetType(Constants.EncryptedData).AsSpan());
            var retEncryptedData =
                Automatica.Core.Driver.Utility.Utils.ByteArrayToString(ret.TlvData.GetType(Constants.EncryptedData).AsSpan());

            Assert.Equal(expectedEncryptedData, retEncryptedData);
            Assert.Equal(expectedTlvResponse.GetType(Constants.State), ret.TlvData.GetType(Constants.State));
            Assert.Equal(expectedTlvResponse.GetType(Constants.EncryptedData), ret.TlvData.GetType(Constants.EncryptedData));

            var expectedHttpResponse =
                "485454502F312E3120323030204F4B0D0A436F6E74656E742D4C656E6774683A203134300D0A436F6E74656E742D547970653A206170706C69636174696F6E2F70616972696E672B746C76380D0A446174653A2053756E2C203139204A616E20323032302031353A33313A313320474D540D0A436F6E6E656374696F6E3A206B6565702D616C6976650D0A0D0A0601060587B0E4A7AA382866E824DB4159CC0ECD24900136BE360FD6AE64481BF799B1ECC918ECB887285A8DCD5B6F90AA410253451FD1BC638CAE716CBAB166F763108633555A6BFA311662986EA2D1EB83B76D195724B9BBDDF7902DFD3A16E1BBD5BB8E5A5A6E3A56E8EEC21C3F06ED2CCE21EA17426407D0A1B35C9D692F5A5EE15ECB7AC662ADE25AB7";
            var expectedHttpResponseArray =
                Automatica.Core.Driver.Utility.Utils.StringToByteArray(expectedHttpResponse);

            var requestTime  = new DateTime(2020, 01, 19, 15, 31, 13, DateTimeKind.Utc);
            var httpResponse =
                HttpServerConnection.GetHttpResponse("HTTP/1.1", PairSetupReturn.ContentType, TlvParser.Serialize(ret.TlvData), requestTime);

            Assert.Equal(expectedHttpResponseArray, httpResponse);
        }
Ejemplo n.º 6
0
 public void Logout()
 {
     this.password = "";
     connection.Logout();
     innovator  = null;
     connection = null;
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
0
        public override void Connect(IReadOnlyCollection <Component> instanceComponents)
        {
            Logger.Instance.Log(LogLevel.Info, "\nConfiguring component ({0}) to work with component({1}):\n", ConversionComponentId, DatabaseComponentId);

            ConversionComponent conversionComponent = instanceComponents.Single(c => c.Id == ConversionComponentId) as ConversionComponent;
            DatabaseComponent   databaseComponent   = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent;

            HttpServerConnection connection = ServerConnectionFactory.GetServerConnection(databaseComponent);
            Innovator            innovator  = new Innovator(connection);

            Item conversionItem = innovator.newItem("ConversionServer", "merge");

            conversionItem.setAttribute("where", string.Format(CultureInfo.InvariantCulture, "[name]='{0}'", conversionComponent.Name));
            conversionItem.setProperty("name", conversionComponent.Name);
            conversionItem.setProperty("url", conversionComponent.ConversionServiceAsmxUrl);
            conversionItem.setProperty("impersonation_user_id", "EB2D5AA617FB41A28F081345B8B5FECB");
            conversionItem = conversionItem.apply();

            if (conversionItem.isError())
            {
                throw new ConnectException(
                          string.Format(CultureInfo.InvariantCulture, "Couldn't connect conversion component '{0}' with database '{1}'. {2}",
                                        ConversionComponentId,
                                        DatabaseComponentId,
                                        conversionItem.ToString()));
            }

            conversionComponent.TargetFileSystem.XmlHelper.XmlPoke(conversionComponent.PathToConfig, "/configuration/ConversionServer/InnovatorServer/@url", databaseComponent.InnovatorServerAspxUrl);
        }
        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);
            }
        }
        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);
        }
Ejemplo n.º 12
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!");
            }
        }
Ejemplo n.º 13
0
        public override void Connect(IReadOnlyCollection <Component> instanceComponents)
        {
            Logger.Instance.Log(LogLevel.Info, "\nConfiguring component ({0}) to work with component({1}):\n", VaultComponentId, DatabaseComponentId);

            VaultComponent    vaultComponent    = instanceComponents.Single(c => c.Id == VaultComponentId) as VaultComponent;
            DatabaseComponent databaseComponent = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent;

            HttpServerConnection connection = ServerConnectionFactory.GetServerConnection(databaseComponent);
            Innovator            innovator  = new Innovator(connection);

            Item vaultItem = innovator.newItem("Vault", "merge");

            vaultItem.setAttribute("where", string.Format(CultureInfo.InvariantCulture, "[name]='{0}'", vaultComponent.Name));
            vaultItem.setProperty("name", vaultComponent.Name);
            vaultItem.setProperty("vault_url_pattern", vaultComponent.VaultServerAspxUrl);
            vaultItem = vaultItem.apply();

            if (vaultItem.isError())
            {
                throw new ConnectException(
                          string.Format(CultureInfo.InvariantCulture, "Couldn't connect vault component '{0}' with database '{1}'. {2}",
                                        VaultComponentId,
                                        DatabaseComponentId,
                                        vaultItem.ToString()));
            }

            vaultComponent.TargetFileSystem.XmlHelper.XmlPoke(vaultComponent.PathToConfig, "/configuration/appSettings/add[@key = 'InnovatorServerUrl']/@value", databaseComponent.InnovatorServerAspxUrl);
        }
Ejemplo n.º 14
0
 private void btn_disconnection_Click(object sender, EventArgs e)
 {
     mc_conn      = null;
     mc_innovator = null;
     SettingConnectionButton(false);
     SettingCheckItemButton(false);
 }
Ejemplo n.º 15
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>");
            }
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
 internal HttpDescribeRuntimeMap(HttpServerConnection conn)
 {
     _conn     = conn;
     this.Name = null;
     this.RequestedFeatures  = 0;
     this.IconWidth          = 16;
     this.IconHeight         = 16;
     this.IconFormat         = "PNG"; //NOXLATE
     this.IconsPerScaleRange = 25;
 }
Ejemplo n.º 19
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();
            }
        }
Ejemplo n.º 20
0
 internal HttpDescribeRuntimeMap(HttpServerConnection conn)
 {
     _conn = conn;
     this.Name = null;
     this.RequestedFeatures = 0;
     this.IconWidth = 16;
     this.IconHeight = 16;
     this.IconFormat = "PNG"; //NOXLATE
     this.IconsPerScaleRange = 25;
 }
Ejemplo n.º 21
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);
            }
        }
Ejemplo n.º 22
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);
        }
        public void ApplyAml(string aml)
        {
            HttpServerConnection connection = ServerConnectionFactory.GetServerConnection(this);
            Innovator            innovator  = new Innovator(connection);
            Item result = innovator.applyAML(aml);

            if (result.isError())
            {
                Logger.Instance.Log(LogLevel.Error, result.ToString());

                throw new Exception(string.Format(CultureInfo.InvariantCulture, "Failed to apply AML {0}.", aml));
            }
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
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!");
            }
        }
        /// <summary>
        /// We need use reflection here, because now it is impossible to set locale and time_zone in HttpServerConnection in any
        /// other way.
        /// </summary>
        /// <param name="obj">instance of HttpServerConnection.</param>
        /// <param name="locale">locale string</param>
        /// <param name="timeZone">timeZone string</param>
        private void SetLocale(HttpServerConnection obj, string locale, string timeZone)
        {
            try
            {
                PropertyInfo propLocale = obj.GetType().BaseType.GetProperty("Locale", BindingFlags.Instance | BindingFlags.NonPublic);
                propLocale.SetValue(obj, locale, null);

                PropertyInfo propTimeZone = obj.GetType().BaseType.GetProperty("TimeZoneName", BindingFlags.Instance | BindingFlags.NonPublic);
                propTimeZone.SetValue(obj, timeZone, null);
            }
            catch (Exception exc)
            {
                throw new CustomException("Failed to set locale and time_zone properties", exc);
            }
        }
Ejemplo n.º 28
0
        void login(string url, string db, string uname, string pwd)
        {
            HttpServerConnection conn = Aras.IOM.IomFactory.CreateHttpServerConnection(url, db, uname, pwd);

            Console.WriteLine("Trying to login as '{0}'...", uname);
            Item log_result = conn.Login();

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

            this.inn = new Innovator(conn);

            Console.WriteLine("Logged in as user '{0}'", uname);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Connecting to the Aras Instance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnect_Click(object sender, EventArgs e)
        {
            string url      = tbUrl.Text;
            string database = tbDb.Text;
            string login    = tbLogin.Text;
            string pass     = tbPass.Text;

            try
            {
                conn = MyIConnection(url, database, login, pass);
            }
            catch (Exception)
            {
                MessageBox.Show("Connection Failed");
            }
        }
Ejemplo n.º 30
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;
                    }
                }
            }
        }
Ejemplo n.º 31
0
        static ConnectionProviderRegistry()
        {
            _ctors     = new Dictionary <string, ConnectionFactoryMethod>();
            _providers = new List <ConnectionProviderEntry>();
            _callCount = new Dictionary <string, int>();

            //Maestro.Http is now built-in
            var httpProvider = HTTP_PROVIDER.ToUpper();

            _ctors[httpProvider] = new ConnectionFactoryMethod((initParams) =>
            {
                var conn = new HttpServerConnection(initParams);
                return(conn);
            });
            _providers.Add(new ConnectionProviderEntry(httpProvider, "HTTP Connection Provider", null, true));
            _callCount[httpProvider] = 0;
        }
Ejemplo n.º 32
0
        public static void RealMain(string[] _args)
        {
            Library.UsageReporter.Reporter.Initialize();

            List<string> args = new List<string>(_args);
            Dictionary<string, string> options = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args);

            foreach (string s in args)
                if (
                    s.Equals("help", StringComparison.InvariantCultureIgnoreCase) ||
                    s.Equals("/help", StringComparison.InvariantCultureIgnoreCase) ||
                    s.Equals("usage", StringComparison.InvariantCultureIgnoreCase) ||
                    s.Equals("/usage", StringComparison.InvariantCultureIgnoreCase))
                    options["help"] = "";

            if (options.ContainsKey("help"))
            {
                Console.WriteLine("Supported commandline arguments:");
                Console.WriteLine();

                foreach (Library.Interface.ICommandLineArgument arg in SupportedCommands)
                    Console.WriteLine("--{0}: {1}", arg.Name, arg.LongDescription);

                Console.WriteLine("Additionally, these server options are also supported:");
                Console.WriteLine();

                foreach (Library.Interface.ICommandLineArgument arg in Duplicati.Server.Program.SupportedCommands)
                    Console.WriteLine("--{0}: {1}", arg.Name, arg.LongDescription);

                return;
            }            
            
            options.TryGetValue(BROWSER_COMMAND_OPTION, out _browser_command);
            
            string toolkit;
            if (!options.TryGetValue(TOOLKIT_OPTION, out toolkit))
                toolkit = GetDefaultToolKit();
            else 
            {
                if (TOOLKIT_WINDOWS_FORMS.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
                    toolkit = TOOLKIT_WINDOWS_FORMS;
#if __MonoCS__ || __WindowsGTK__                
                else if (TOOLKIT_GTK.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
                    toolkit = TOOLKIT_GTK;
                else if (TOOLKIT_GTK_APP_INDICATOR.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
                    toolkit = TOOLKIT_GTK_APP_INDICATOR;
#endif
                else if (TOOLKIT_COCOA.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
                    toolkit = TOOLKIT_COCOA;
                else
                    toolkit = GetDefaultToolKit();
            }

            HostedInstanceKeeper hosted = null;
            bool openui = false;
            string password = null;
            bool saltedpassword = false;
            if (!Library.Utility.Utility.ParseBoolOption(options, NOHOSTEDSERVER_OPTION))
            {
                try
                {
                    hosted = new HostedInstanceKeeper(_args);
                }
                catch (Server.SingleInstance.MultipleInstanceException)
                {
                    return;
                }

                // We have a hosted server, if this is the first run, 
                // we should open the main page
                openui = Duplicati.Server.Program.IsFirstRun || Duplicati.Server.Program.ServerPortChanged;
                password = Duplicati.Server.Program.DataConnection.ApplicationSettings.WebserverPassword;
                saltedpassword = true;
            }

            using (hosted)
            {
                string url;
                if (!options.TryGetValue(HOSTURL_OPTION, out url))
                {
                    if (hosted == null)
                    {
                        url = DEFAULT_HOSTURL;
                    }
                    else
                    {
                        int port = Duplicati.Server.Program.ServerPort;
                        url = "http://127.0.0.1:" + port;
                    }
                }

                string pwd;
                if (options.TryGetValue("webserver-password", out pwd))
                {
                    password = pwd;
                    saltedpassword = false;
                }

                using (Connection = new HttpServerConnection(new Uri(url), password, saltedpassword))
                {
                    using(var tk = RunTrayIcon(toolkit))
                    {
                        if (hosted != null && Server.Program.Instance != null)
                            Server.Program.Instance.SecondInstanceDetected += new Server.SingleInstance.SecondInstanceDelegate(x => { tk.ShowUrlInWindow(url); });
                        
                        // TODO: If we change to hosted browser this should be a callback
                        if (openui)
                        {
                            try 
                            {
                                tk.ShowUrlInWindow(Connection.StatusWindowURL);

                                Duplicati.Server.Program.IsFirstRun = false;
                                Duplicati.Server.Program.ServerPortChanged = false;
                            } 
                            catch
                            {
                            }
                        }

                        // If the server shuts down, shut down the tray-icon as well
                        Action shutdownEvent = () =>
                        {
                            tk.InvokeExit();
                        };

                        if (hosted != null)
                            hosted.InstanceShutdown += shutdownEvent;

                        tk.Init(_args);

                        // Make sure that the server shutdown does not access the tray-icon,
                        // as it would be disposed by now
                        if (hosted != null)
                            hosted.InstanceShutdown -= shutdownEvent;
                    }
                }
            }
        }
        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);
            }
        }
        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;
        }
Ejemplo n.º 35
0
 internal HttpCapabilities(IServerConnection parent)
     : base(parent)
 {
     _implConn = parent as HttpServerConnection;
 }
Ejemplo n.º 36
0
 internal HttpGetFdoCacheInfo(HttpServerConnection conn)
 {
     _conn = conn;
 }