Exemplo n.º 1
0
        /// <summary>
        /// Default constructor (new)
        /// </summary>
        public frmEmailEdit()
        {
            // Required for Windows Form Designer support
              InitializeComponent();
              m_UpdateAction = false;
              CurrentID = new DBGuid(Guid.NewGuid());
              m_IsNewsMail = true;
              pHeader.Text2 = "Új hírlevél létrehozása";

              m_currentMail = new Email(CurrentID);
        }
Exemplo n.º 2
0
        public List <RegionData> RunCommand(MySqlCommand cmd)
        {
            List <RegionData> retList = new List <RegionData>();

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();
                cmd.Connection = dbcon;

                using (IDataReader result = cmd.ExecuteReader())
                {
                    while (result.Read())
                    {
                        RegionData ret = new RegionData();
                        ret.Data = new Dictionary <string, object>();

                        ret.RegionID = DBGuid.FromDB(result["uuid"]);
                        ret.ScopeID  = DBGuid.FromDB(result["ScopeID"]);

                        ret.RegionName = result["regionName"].ToString();
                        ret.posX       = Convert.ToInt32(result["locX"]);
                        ret.posY       = Convert.ToInt32(result["locY"]);
                        ret.sizeX      = Convert.ToInt32(result["sizeX"]);
                        ret.sizeY      = Convert.ToInt32(result["sizeY"]);

                        if (m_ColumnNames == null)
                        {
                            m_ColumnNames = new List <string>();

                            DataTable schemaTable = result.GetSchemaTable();
                            foreach (DataRow row in schemaTable.Rows)
                            {
                                if (row["ColumnName"] != null)
                                {
                                    m_ColumnNames.Add(row["ColumnName"].ToString());
                                }
                            }
                        }

                        foreach (string s in m_ColumnNames)
                        {
                            if (s == "uuid")
                            {
                                continue;
                            }
                            if (s == "ScopeID")
                            {
                                continue;
                            }
                            if (s == "regionName")
                            {
                                continue;
                            }
                            if (s == "locX")
                            {
                                continue;
                            }
                            if (s == "locY")
                            {
                                continue;
                            }

                            ret.Data[s] = result[s].ToString();
                        }

                        retList.Add(ret);
                    }
                }
            }

            return(retList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Remove a NewsPicture from the list.
        /// </summary>
        private void RemoveFile()
        {
            DBGuid ID = new DBGuid();
              ID.Value = dtgFiles.GetSelectedRowCell("ID");
              if (ID.IsNull)
              {
            MessageBox.Show("Válasszon eltávolítani kívánt fájlt a listában!", "NDI HelpDesk Adminisztrátor",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
            return;
              }

              try
              {
            // Logical undelete source item
            EmailAttachment selected = (EmailAttachment) m_currentMail.EmailAttachments[ID.ToString()];
            m_currentMail.EmailAttachments.Delete(selected);

            // Refresh grid
            FillDatagrid(DBGuid.Null);
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a fájl eltávolítása során.", ex);
              }
        }
Exemplo n.º 4
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill datagrid with data, get relations for keyword
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            if (tabPageAttachment == null)
            {
              return;
            }
            string sortColumn = "Name";
            int selectedRow = -1;

            // Storing the previous sort order
            if (dtgFiles.DataSource != null)
            {
              sortColumn = ((DataTable) dtgFiles.DataSource).DefaultView.Sort;
            }
            if (m_currentMail.EmailAttachments != null)
            {
              DataTable dt = m_currentMail.EmailAttachments.CurrentAsDatatable;
              dt.DefaultView.Sort = sortColumn;
              dtgFiles.DataSource = dt;

              // locates the row specified by ID param
              if (! ID.IsNull && dtgFiles.BindingContext != null)
              {
            BindingManagerBase bm = dtgFiles.BindingContext[dtgFiles.DataSource, dtgFiles.DataMember];
            DataRow dr;
            int nPositionStart = bm.Position;
            for (int i = 0; i < bm.Count; i++)
            {
              dr = ((DataRowView) bm.Current).Row;
              if (ID.Value.Equals(dr["ID"]))
              {
                selectedRow = i;
                break;
              }
              bm.Position += 1;
            }
            bm.Position = nPositionStart;
              }

              // makes the row selected
              if (selectedRow <= ((DataTable) dtgFiles.DataSource).DefaultView.Count && selectedRow > -1)
              {
            dtgFiles.Select(selectedRow);
            dtgFiles.CurrentRowIndex = selectedRow;
              }
            }
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex);
              }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Edit constructor
 /// </summary>
 public frmEmailEdit(DBGuid ID)
 {
     // Required for Windows Form Designer support
       InitializeComponent();
       m_UpdateAction = true;
       CurrentID = ID;
       pHeader.Text2 = "Hírlevél szerkesztése";
 }
Exemplo n.º 6
0
        protected T[] DoQuery(MySqlCommand cmd)
        {
            List <T> result = new List <T>();

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();
                cmd.Connection = dbcon;

                using (IDataReader reader = cmd.ExecuteReader())
                {
                    if (reader == null)
                    {
                        return(new T[0]);
                    }

                    CheckColumnNames(reader);

                    while (reader.Read())
                    {
                        T row = new T();

                        foreach (string name in m_Fields.Keys)
                        {
                            if (reader[name] is DBNull)
                            {
                                continue;
                            }
                            if (m_Fields[name].FieldType == typeof(bool))
                            {
                                int v = Convert.ToInt32(reader[name]);
                                m_Fields[name].SetValue(row, v != 0 ? true : false);
                            }
                            else if (m_Fields[name].FieldType == typeof(UUID))
                            {
                                m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name]));
                            }
                            else if (m_Fields[name].FieldType == typeof(int))
                            {
                                int v = Convert.ToInt32(reader[name]);
                                m_Fields[name].SetValue(row, v);
                            }
                            else
                            {
                                m_Fields[name].SetValue(row, reader[name]);
                            }
                        }

                        if (m_DataField != null)
                        {
                            Dictionary <string, string> data =
                                new Dictionary <string, string>();

                            foreach (string col in m_ColumnNames)
                            {
                                data[col] = reader[col].ToString();
                                if (data[col] == null)
                                {
                                    data[col] = String.Empty;
                                }
                            }

                            m_DataField.SetValue(row, data);
                        }

                        result.Add(row);
                    }
                }
            }

            return(result.ToArray());
        }
        public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
        {
            string query = string.Empty;

            query += "SELECT * FROM userprofile WHERE ";
            query += "useruuid = :Id";

            try
            {
                using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString))
                {
                    dbcon.Open();
                    using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
                    {
                        cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId));

                        using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
                        {
                            if (reader.HasRows)
                            {
                                // m_log.DebugFormat("[PROFILES_DATA]" +
                                //                  ": Getting data for {0}.", props.UserId);
                                reader.Read();
                                props.WebUrl           = (string)reader["profileURL"].ToString();
                                props.ImageId          = DBGuid.FromDB(reader["profileImage"]);
                                props.AboutText        = (string)reader["profileAboutText"];
                                props.FirstLifeImageId = DBGuid.FromDB(reader["profileFirstImage"]);
                                props.FirstLifeText    = (string)reader["profileFirstText"];
                                props.PartnerId        = DBGuid.FromDB(reader["profilePartner"]);
                                props.WantToMask       = (int)reader["profileWantToMask"];
                                props.WantToText       = (string)reader["profileWantToText"];
                                props.SkillsMask       = (int)reader["profileSkillsMask"];
                                props.SkillsText       = (string)reader["profileSkillsText"];
                                props.Language         = (string)reader["profileLanguages"];
                            }
                            else
                            {
                                //m_log.DebugFormat("[PROFILES_DATA]" +
                                //                 ": No data for {0}", props.UserId);

                                props.WebUrl           = string.Empty;
                                props.ImageId          = UUID.Zero;
                                props.AboutText        = string.Empty;
                                props.FirstLifeImageId = UUID.Zero;
                                props.FirstLifeText    = string.Empty;
                                props.PartnerId        = UUID.Zero;
                                props.WantToMask       = 0;
                                props.WantToText       = string.Empty;
                                props.SkillsMask       = 0;
                                props.SkillsText       = string.Empty;
                                props.Language         = string.Empty;
                                props.PublishProfile   = false;
                                props.PublishMature    = false;

                                query  = "INSERT INTO userprofile (";
                                query += "useruuid, ";
                                query += "\"profilePartner\", ";
                                query += "\"profileAllowPublish\", ";
                                query += "\"profileMaturePublish\", ";
                                query += "\"profileURL\", ";
                                query += "\"profileWantToMask\", ";
                                query += "\"profileWantToText\", ";
                                query += "\"profileSkillsMask\", ";
                                query += "\"profileSkillsText\", ";
                                query += "\"profileLanguages\", ";
                                query += "\"profileImage\", ";
                                query += "\"profileAboutText\", ";
                                query += "\"profileFirstImage\", ";
                                query += "\"profileFirstText\") VALUES (";
                                query += ":userId, ";
                                query += ":profilePartner, ";
                                query += ":profileAllowPublish, ";
                                query += ":profileMaturePublish, ";
                                query += ":profileURL, ";
                                query += ":profileWantToMask, ";
                                query += ":profileWantToText, ";
                                query += ":profileSkillsMask, ";
                                query += ":profileSkillsText, ";
                                query += ":profileLanguages, ";
                                query += ":profileImage, ";
                                query += ":profileAboutText, ";
                                query += ":profileFirstImage, ";
                                query += ":profileFirstText)";

                                dbcon.Close();
                                dbcon.Open();

                                using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon))
                                {
                                    //m_log.DebugFormat("[PROFILES_DATA]" +
                                    //                  ": Adding new data for {0}", props.UserId);

                                    put.Parameters.Add(m_database.CreateParameter("userId", props.UserId));
                                    put.Parameters.Add(m_database.CreateParameter("profilePartner", props.PartnerId));
                                    put.Parameters.Add(m_database.CreateParameter("profileAllowPublish", props.PublishProfile));
                                    put.Parameters.Add(m_database.CreateParameter("profileMaturePublish", props.PublishMature));
                                    put.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl));
                                    put.Parameters.Add(m_database.CreateParameter("profileWantToMask", props.WantToMask));
                                    put.Parameters.Add(m_database.CreateParameter("profileWantToText", props.WantToText));
                                    put.Parameters.Add(m_database.CreateParameter("profileSkillsMask", props.SkillsMask));
                                    put.Parameters.Add(m_database.CreateParameter("profileSkillsText", props.SkillsText));
                                    put.Parameters.Add(m_database.CreateParameter("profileLanguages", props.Language));
                                    put.Parameters.Add(m_database.CreateParameter("profileImage", props.ImageId));
                                    put.Parameters.Add(m_database.CreateParameter("profileAboutText", props.AboutText));
                                    put.Parameters.Add(m_database.CreateParameter("profileFirstImage", props.FirstLifeImageId));
                                    put.Parameters.Add(m_database.CreateParameter("profileFirstText", props.FirstLifeText));

                                    put.ExecuteNonQuery();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error("[PROFILES_DATA]: GetAvatarProperties exception ", e);
                result = e.Message;
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
        private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create)
        {
            EstateSettings es = new EstateSettings();

            es.OnSave += StoreEstateSettings;

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();

                cmd.Connection = dbcon;

                bool found = false;

                using (IDataReader r = cmd.ExecuteReader())
                {
                    if (r.Read())
                    {
                        found = true;

                        foreach (string name in FieldList)
                        {
                            if (m_FieldMap[name].FieldType == typeof(bool))
                            {
                                m_FieldMap[name].SetValue(es, Convert.ToInt32(r[name]) != 0);
                            }
                            else if (m_FieldMap[name].FieldType == typeof(UUID))
                            {
                                m_FieldMap[name].SetValue(es, DBGuid.FromDB(r[name]));
                            }
                            else
                            {
                                m_FieldMap[name].SetValue(es, r[name]);
                            }
                        }
                    }
                }

                if (!found && create)
                {
                    // Migration case
                    List <string> names = new List <string>(FieldList);

                    names.Remove("EstateID");

                    string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";

                    using (MySqlCommand cmd2 = dbcon.CreateCommand())
                    {
                        cmd2.CommandText = sql;
                        cmd2.Parameters.Clear();

                        foreach (string name in FieldList)
                        {
                            if (m_FieldMap[name].GetValue(es) is bool)
                            {
                                if ((bool)m_FieldMap[name].GetValue(es))
                                {
                                    cmd2.Parameters.AddWithValue("?" + name, "1");
                                }
                                else
                                {
                                    cmd2.Parameters.AddWithValue("?" + name, "0");
                                }
                            }
                            else
                            {
                                cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
                            }
                        }

                        cmd2.ExecuteNonQuery();

                        cmd2.CommandText = "select LAST_INSERT_ID() as id";
                        cmd2.Parameters.Clear();

                        using (IDataReader r = cmd2.ExecuteReader())
                        {
                            r.Read();
                            es.EstateID = Convert.ToUInt32(r["id"]);
                        }

                        cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
                        cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString());
                        cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());

                        // This will throw on dupe key
                        try { cmd2.ExecuteNonQuery(); }
                        catch (Exception) { }

                        es.Save();
                    }
                }
            }

            LoadBanList(es);

            es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
            es.EstateAccess   = LoadUUIDList(es.EstateID, "estate_users");
            es.EstateGroups   = LoadUUIDList(es.EstateID, "estate_groups");
            return(es);
        }
Exemplo n.º 9
0
        public List <RegionData> RunCommand(MySqlCommand cmd)
        {
            List <RegionData> retList = new List <RegionData>();

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();
                cmd.Connection = dbcon;

                using (IDataReader result = cmd.ExecuteReader())
                {
                    while (result.Read())
                    {
                        RegionData ret = new RegionData();
                        ret.Data = new Dictionary <string, object>();

                        ret.RegionID = DBGuid.FromDB(result["uuid"]);
                        ret.ScopeID  = DBGuid.FromDB(result["ScopeID"]);

                        ret.RegionName = result["regionName"].ToString();
                        ret.posX       = Convert.ToInt32(result["locX"]);
                        ret.posY       = Convert.ToInt32(result["locY"]);
                        ret.sizeX      = Convert.ToInt32(result["sizeX"]);
                        ret.sizeY      = Convert.ToInt32(result["sizeY"]);

                        CheckColumnNames(result);

                        foreach (string s in m_ColumnNames)
                        {
                            if (s == "uuid")
                            {
                                continue;
                            }
                            if (s == "ScopeID")
                            {
                                continue;
                            }
                            if (s == "regionName")
                            {
                                continue;
                            }
                            if (s == "locX")
                            {
                                continue;
                            }
                            if (s == "locY")
                            {
                                continue;
                            }

                            object value = result[s];
                            if (value is DBNull)
                            {
                                ret.Data[s] = null;
                            }
                            else
                            {
                                ret.Data[s] = result[s].ToString();
                            }
                        }

                        retList.Add(ret);
                    }
                }
            }

            return(retList);
        }