示例#1
0
文件: Settings.cs 项目: hnjm/Pos-3
        private void btnTestDatabaseConnection_Click(object sender, EventArgs e)
        {
            SaveValues();
            RegistrySettings.writeValues();
            CoreFeature.getInstance().resetConnection();
            if (CoreFeature.getInstance().getDataConnection() == null)
            {
                MessageBox.Show("Can not connect to the database");
            }
            else
            {
                MessageBox.Show("Connection established");
            }

            /*
             * try
             * {
             *  SqlConnection con = new SqlConnection("Server=" + RegistrySettings.SqlHost + ";Database=" + RegistrySettings.SqlDatabase + ";Uid=" + RegistrySettings.SqlUsername + ";Pwd=" + RegistrySettings.SqlPassword);
             *  con.Open();
             *  if (con.State == ConnectionState.Open)
             *  {
             *      MessageBox.Show("Connection success!");
             *      con.Close();
             *      con.Dispose();
             *  }
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show("Connection error : " + ex.Message);
             * }*/
        }
示例#2
0
        public EmailAccount(string accountName, Settings settings)
        {
            InitializeComponent();
            this.accountName = accountName;
            this.settings    = settings;
            SqlConnection connection = CoreFeature.getInstance().getDataConnection();
            SqlCommand    cmd        = connection.CreateCommand();

            cmd.CommandText = "select * from account where name='" + accountName + "'";
            cmd.CommandType = CommandType.Text;
            SqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())
            {
                txtName.Text      = rdr.GetString(rdr.GetOrdinal("name"));
                txtServer.Text    = rdr.GetString(rdr.GetOrdinal("server"));
                txtPort.Value     = rdr.GetInt32(rdr.GetOrdinal("port"));
                chkUseSSL.Checked = rdr.GetByte(rdr.GetOrdinal("use_ssl")) == 1;
                txtUsername.Text  = rdr.GetString(rdr.GetOrdinal("username"));
                txtPassword.Text  = Cryptho.Decrypt(rdr.GetString(rdr.GetOrdinal("password")));
                chkActive.Checked = rdr.GetByte(rdr.GetOrdinal("active")) == 1;
            }

            cmd.Dispose();
            rdr.Close();
            connection.Close();
        }
示例#3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string     sql = "select * from [users] where [userid]=@userid and [password]=@password";
            SqlCommand cmd = new SqlCommand(sql, CoreFeature.getInstance().getDataConnection());

            cmd.Parameters.AddWithValue("userid", ((StaffModel)cboUsername.SelectedValue).Value);
            cmd.Parameters.AddWithValue("password", txtPassword.Text);
            SqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())
            {
                if (rdr.GetByte(rdr.GetOrdinal("isactive")) == 0)
                {
                    MessageBox.Show("Your account has been deactivated. Please consult your administration regarding this");
                    rdr.Close();
                    cmd.Dispose();
                    return;
                }
                Program.loginUser = new StaffModel(rdr.GetInt32(rdr.GetOrdinal("userid")), rdr.GetString(rdr.GetOrdinal("username")), "");
                rdr.Close();
                cmd.Dispose();
                graceClose = true;
                Close();
            }
            else
            {
                MessageBox.Show("You have supply a wrong credential", Application.ProductName);
                rdr.Close();
                cmd.Dispose();
                return;
            }
        }
示例#4
0
        private bool saveConnection()
        {
            SqlConnection connection = CoreFeature.getInstance().getDataConnection();
            SqlCommand    cmd        = connection.CreateCommand();

            if (accountName == "")
            {
                cmd.CommandText = "insert into account(name,server,port,use_ssl,username,password,active) values ('" + txtName.Text + "','" + txtServer.Text + "'," + txtPort.Value + "," + Convert.ToInt32(chkUseSSL.Checked) + ",'" + txtUsername.Text + "','" + Cryptho.Encrypt(txtPassword.Text) + "'," + Convert.ToInt32(chkActive.Checked) + ")";
            }
            else
            {
                cmd.CommandText = "update account set name='" + txtName.Text + "', server='" + txtServer.Text + "',port=" + txtPort.Value + ",use_ssl=" + Convert.ToInt32(chkUseSSL.Checked) + ",username='******',password='******', active=" + Convert.ToInt32(chkActive.Checked) + " where name='" + accountName + "'";
            }
            cmd.CommandType = CommandType.Text;
            int rowAffected = cmd.ExecuteNonQuery();

            if (rowAffected != 1)
            {
                MessageBox.Show("Error occured in saving your connection info. Please correct them before testing connection");
                cmd.Dispose();
                connection.Close();
                return(false);
            }
            settings.updateListAccountName(txtName.Text);
            cmd.Dispose();
            connection.Close();

            return(true);
        }
示例#5
0
文件: CoreService.cs 项目: hnjm/Pos-3
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            timer.Stop();
            string sql;

            CoreFeature.getInstance().LogActivity(LogLevel.Debug, "Begin timed activity : Logging to email account and processing the rules", EventLogEntryType.Information);
            try
            {
                //1. LOOP ALL EMAIL ACCOUNTS
                sql = "select name, server,port,use_ssl,username,password,active from account where active=1";
                SqlCommand     cmdAccount  = new SqlCommand(sql, CoreFeature.getInstance().getDataConnection());
                SqlDataReader  rdrAccount  = cmdAccount.ExecuteReader();
                List <Account> listAccount = new List <Account>();
                while (rdrAccount.Read())
                {
                    Account emailAccount = new Account(rdrAccount.GetString(rdrAccount.GetOrdinal("name")), rdrAccount.GetString(rdrAccount.GetOrdinal("server")), rdrAccount.GetInt32(rdrAccount.GetOrdinal("port")), rdrAccount.GetString(rdrAccount.GetOrdinal("username")), Cryptho.Decrypt(rdrAccount.GetString(rdrAccount.GetOrdinal("password"))), rdrAccount.GetByte(rdrAccount.GetOrdinal("use_ssl")) == 1, rdrAccount.GetByte(rdrAccount.GetOrdinal("active")) == 1);
                    listAccount.Add(emailAccount);
                    CoreFeature.getInstance().LogActivity(LogLevel.Debug, "Will use active email " + emailAccount.name, EventLogEntryType.Information);
                }
                rdrAccount.Close();

                //2. LOOP ALL NEW MESSAGES
                foreach (Account emailAccount in listAccount)
                {
                    CoreFeature.getInstance().LogActivity(LogLevel.Debug, "Logging in to email account " + emailAccount.name, EventLogEntryType.Information);
                    SqlDataReader rdrInbox = null;
                    sql = "SELECT count(*) FROM inbox i, account a where i.account_name = a.name and a.name=@name";
                    SqlCommand cmdInbox = new SqlCommand(sql, CoreFeature.getInstance().getDataConnection());
                    cmdInbox.Parameters.AddWithValue("name", emailAccount.name);
                    rdrInbox = cmdInbox.ExecuteReader();

                    if (rdrInbox.Read())
                    {
                        if (rdrInbox.GetInt32(0) == 0)
                        {
                            CoreFeature.getInstance().LogActivity(LogLevel.Debug, "No messages in inbox, try to fetch all last 30 days message to test the rule", EventLogEntryType.Information);
                            rdrInbox.Dispose();
                            CoreFeature.getInstance().FetchRecentMessages(emailAccount, true);
                        }
                        else
                        {
                            CoreFeature.getInstance().LogActivity(LogLevel.Debug, "Inbox already consisted of previous fetched message, now only fetch new message", EventLogEntryType.Information);
                            rdrInbox.Dispose();
                            CoreFeature.getInstance().FetchRecentMessages(emailAccount, false);
                        }
                    }
                    rdrInbox.Close();
                    cmdInbox.Dispose();
                }
            }
            catch (Exception ex)
            {
                CoreFeature.getInstance().LogActivity(LogLevel.Debug, "[Internal Application Error] " + ex.Message, EventLogEntryType.Error);
                if (CoreFeature.getInstance().getDataConnection() != null)
                {
                    CoreFeature.getInstance().getDataConnection().Close();
                }
            }
            timer.Start();
        }
        //	private void getAllInvariants(Map allInvariants) {
        //		InvariantsCollector collector = new InvariantsCollector(this.getJmiClassifier(), allInvariants);
        //		collector.traverseAllAncestors();
        //	}
        public CoreModelElement addDefinedElement(
            string source,
            string name,
            CoreClassifier type)
        {
            List <object> allSubClasses = classifier.getAllSubClasses();

            foreach (CoreClassifier subClass in allSubClasses)
            {
                Environment env = subClass.getEnvironmentWithoutParents();

                if (env.lookup(name) != null)
                {
                    string errorMessage = "<{0}> already defined in a derived classifier";
                    throw new NameClashException(string.Format(errorMessage, new object[] { name }));
                }
            }

            CoreFeature element = createOclDefinedAttribute(source, name, type);

            element.setFeatureOwner(classifier);
            element.setElemOwner(classifier);

            this.definedFeatures.Add(name, element);
            addElementToDefinedFeaturesBySource(source, element);

            return(element);
        }
示例#7
0
文件: Settings.cs 项目: hnjm/Pos-3
        public Settings()
        {
            InitializeComponent();

            RegistrySettings.loadValues();


            ReadValues();
            SqlConnection connection = CoreFeature.getInstance().getDataConnection();

            /*
             * lvAccount.Items.Clear();
             *
             * if (connection != null)
             * {
             *  //email accounts
             *  SqlCommand cmd;
             *  SqlDataReader rdr;
             *  cmd = connection.CreateCommand();
             *  cmd.CommandText = "select name from account order by name";
             *  cmd.CommandType = CommandType.Text;
             *  rdr = cmd.ExecuteReader();
             *
             *  while (rdr.Read())
             *  {
             *      lvAccount.Items.Add(rdr.GetString(0));
             *  }
             *  cmd.Dispose();
             *  rdr.Dispose();
             *
             *  connection.Close();
             * }
             */
            cboDatabaseType.SelectedIndex = 0;
        }
示例#8
0
文件: CoreService.cs 项目: hnjm/Pos-3
 protected override void OnStart(string[] args)
 {
     RegistrySettings.loadValues();
     CoreFeature.getInstance().LogActivity(LogLevel.Normal, "The service was started successfully. Will checking email every " + RegistrySettings.emailCheckInterval + " second(s)", EventLogEntryType.Information);
     timer          = new Timer(RegistrySettings.emailCheckInterval * 1000); // in seconds
     timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     timer.Start();                                                          // <- important
 }
示例#9
0
文件: Settings.cs 项目: hnjm/Pos-3
 private void btnOK_Click(object sender, EventArgs e)
 {
     SaveValues();
     RegistrySettings.writeValues();
     RegistrySettings.loadValues();
     CoreFeature.getInstance().resetConnection();
     Close();
 }
        public void createSpecificStereotype(CoreClassifier classifier, CoreFeature feature, String stereotypeName)
        {
            CorePackage mainPackage = (CorePackage)classifier.getModel().getMainPackage();

            CoreStereotype stereotype = null;
            //CoreStereotype stereotype = new CoreStereotypeImpl();

            //stereotype.setName(stereotypeName);
            //mainPackage.getFoundation().getExtensionMechanisms().getAStereotypeExtendedElement().add(stereotype, (CoreFeature) feature);
        }
        public void createSpecificStereotype(CoreClassifier classifier, CoreFeature feature, String stereotypeName)
        {
            UmlPackage mainPackage = (UmlPackage)classifier.getModel().getMainPackage();

            //verificar
            Stereotype stereotype = mainPackage.getFoundation().getExtensionMechanisms().getStereotype();

            stereotype.setName(stereotypeName);
            mainPackage.getFoundation().getExtensionMechanisms().getAStereotypeExtendedElement().add(stereotype, (Feature)feature);
        }
        private void addElementToDefinedFeaturesBySource(string source, CoreFeature element)
        {
            List <CoreFeature> targetList;

            this.definedFeaturesBySource.TryGetValue(source, out targetList);
            if (targetList == null)
            {
                targetList = new List <CoreFeature>();
            }
            targetList.Add(element);
            this.definedFeaturesBySource.Add(source, targetList);
        }
示例#13
0
    private void InitFeatures()
    {
        _contexts   = Contexts.sharedInstance;
        coreFeature = new CoreFeature(_contexts, true);

        coreFeature.Add(new PlayerBalanceFeature(_contexts, true));
        coreFeature.Add(new HourlyBonusFeature(_contexts, true));
        coreFeature.Add(new PushNotificationsFeature(_contexts, true));

        // FacebookFeature
        // PaymentFeature
        // GamesFeature

        coreFeature.Initialize();
    }
示例#14
0
文件: InboxViewer.cs 项目: hnjm/Pos-3
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 6)
     {
         String     sql = "select body from inbox where idinbox=@idinbox";
         SqlCommand cmd = new SqlCommand(sql, CoreFeature.getInstance().getDataConnection());
         cmd.Parameters.Add(new SqlParameter("idinbox", dataGridView1.Rows[e.RowIndex].Cells[7].Value));
         SqlDataReader rdr = cmd.ExecuteReader();
         if (rdr.Read())
         {
             MessageBox.Show(rdr.GetString(rdr.GetOrdinal("body")));
         }
         rdr.Close();
         cmd.Dispose();
     }
 }
示例#15
0
文件: Settings.cs 项目: hnjm/Pos-3
 private void btnRemoveAccount_Click(object sender, EventArgs e)
 {
     if (lvAccount.SelectedIndex >= 0)
     {
         if (MessageBox.Show("Are you sure you want to delete this account?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             SqlConnection connection = CoreFeature.getInstance().getDataConnection();
             SqlCommand    cmd        = connection.CreateCommand();
             cmd.CommandText = "delete from account where name='" + lvAccount.Text + "'";
             cmd.CommandType = CommandType.Text;
             cmd.ExecuteNonQuery();
             lvAccount.Items.RemoveAt(lvAccount.SelectedIndex);
             cmd.Dispose();
             connection.Close();
         }
     }
 }
示例#16
0
文件: InboxViewer.cs 项目: hnjm/Pos-3
        private void btnShow_Click(object sender, EventArgs e)
        {
            String        sql = "select * from inbox_plain";
            SqlCommand    cmd = new SqlCommand(sql, CoreFeature.getInstance().getDataConnection());
            SqlDataReader rdr = cmd.ExecuteReader();

            dataGridView1.Rows.Clear();
            int i = 0;

            while (rdr.Read())
            {
                DataGridViewButtonColumn buttonBody = new DataGridViewButtonColumn();
                buttonBody.Text = "View";
                dataGridView1.Rows.Add(new object[] { ++i, rdr.GetString(rdr.GetOrdinal("date")), rdr.GetString(rdr.GetOrdinal("sender")), rdr.GetString(rdr.GetOrdinal("sender_ip")), rdr.GetString(rdr.GetOrdinal("to")), rdr.GetString(rdr.GetOrdinal("subject")), "View", rdr.GetInt32(rdr.GetOrdinal("idinbox")) });
            }
            rdr.Close();
            cmd.Dispose();
        }
        public CoreModelElement addDefinedOperation(
            string source,
            string name,
            List <object> paramNames,
            List <object> paramTypes,
            CoreClassifier returnType)
        {
            CoreFeature element = createOclDefinedOperation(source, name, paramNames, paramTypes, returnType);

            element.setFeatureOwner(classifier);
            element.setElemOwner(classifier);
            ModelElementNameGenerator nameGenerator = CoreModelElementNameGeneratorImpl.getInstance();

            string mangledName = nameGenerator.generateNameForOperation(name, paramTypes);

            this.definedFeatures.Add(mangledName, element);
            addElementToDefinedFeaturesBySource(source, element);

            return(element);
        }
示例#18
0
        protected void createSpecificStereotype(CoreFeature feature, String stereotypeName)
        {
            CoreElementFactory umlFactory = new CoreElementFactory();

            umlFactory.createSpecificStereotype(this, feature, stereotypeName);
        }
示例#19
0
文件: CoreService.cs 项目: hnjm/Pos-3
 protected override void OnStop()
 {
     CoreFeature.getInstance().LogActivity(LogLevel.Normal, "The service was stopped successfully.", EventLogEntryType.Information);
 }
示例#20
0
        public LoginDialog()
        {
            InitializeComponent();
            SqlCommand    cmd = new SqlCommand("select userid, username from users where [isactive]=1 order by username", CoreFeature.getInstance().getDataConnection());
            SqlDataReader rdr = cmd.ExecuteReader();

            listStaff = new List <StaffModel>();
            AutoCompleteStringCollection autoCompleteUser = new AutoCompleteStringCollection();

            while (rdr.Read())
            {
                listStaff.Add(new StaffModel(rdr.GetInt32(rdr.GetOrdinal("userid")), rdr.GetString(rdr.GetOrdinal("username")), ""));
                autoCompleteUser.Add(rdr.GetString(rdr.GetOrdinal("username")));
            }

            cboUsername.AutoCompleteCustomSource = autoCompleteUser;
            cboUsername.Items.Clear();
            cboUsername.DisplayMember = "Name";
            cboUsername.DataSource    = listStaff;
            rdr.Close();
            cmd.Dispose();
        }