Skip to content

Commit

Permalink
WebsitePanel bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maestropanel2 committed Jul 11, 2015
1 parent c18f23d commit 7093112
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 204 deletions.
Binary file modified MpImport.v11.suo
Binary file not shown.
1 change: 0 additions & 1 deletion MpMigrate.Core/Discovery/WebsitePanel_Discover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public void SetDatabase()
{
if (isWebSiteExists())
{

System.Configuration.Configuration rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/", WEBSITEPANEL_WEBSITE_NAME);
var connectionStr = rootWebConfig1.ConnectionStrings.ConnectionStrings["EnterpriseServer"].ConnectionString;

Expand Down
370 changes: 192 additions & 178 deletions MpMigrate.Core/MigrateManager.cs

Large diffs are not rendered by default.

64 changes: 45 additions & 19 deletions MpMigrate.Data/Dal/WebSitePanel_MsSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ FROM ServiceItems INNER JOIN
_d.isForwarding = false;
_d.ForwardUrl = "";



_tmp.Add(_d);
}
}
Expand Down Expand Up @@ -142,15 +144,18 @@ FROM ServiceItems INNER JOIN
var password = DataExtensions.GetColumnValue<string>(_read, "PropertyValue");
var ItemName = DataExtensions.GetColumnValue<string>(_read, "ItemName");

var da = new Email();
da.DomainName = domainName;
da.Name = ItemName.Split('@').FirstOrDefault();
da.Password = Decrypt(password);
da.Quota = domainMailBoxSizeQuota;
da.Redirect = String.Empty;
da.RedirectedEmail = String.Empty;

_tmp.Add(da);
if (!String.IsNullOrEmpty(ItemName))
{
var da = new Email();
da.DomainName = domainName;
da.Name = ItemName.Split('@').FirstOrDefault();
da.Password = Decrypt(password);
da.Quota = domainMailBoxSizeQuota;
da.Redirect = String.Empty;
da.RedirectedEmail = String.Empty;

_tmp.Add(da);
}
}
}
}
Expand Down Expand Up @@ -324,7 +329,7 @@ public override List<DatabaseUser> GetDatabaseUsers(int database_id)

//Veritabanı Adını bul
var db = GetDatabaseItem(database_id);

//Veritabanına ait kullanıcıların listesini mysql'den getir.
var databaseUsers = db.dbtype == "mssql" ?
GetDatabaseUsersFromMsSQL(db) :
Expand Down Expand Up @@ -363,7 +368,6 @@ public override List<DatabaseUser> GetDatabaseUsers(int database_id)

_tmp.Add(dbuser);
}


return _tmp;
}
Expand Down Expand Up @@ -595,10 +599,10 @@ private List<String> GetDatabaseUsersFromMySQL(DataBaseItem dbitem)
private List<String> GetDatabaseUsersFromMsSQL(DataBaseItem dbitem)
{
var list = new List<String>();

var _con = GetSQLConnectionString(dbitem);

//MessageBox.Show(_con);
if (!isDatabaseExists(dbitem.Name))
return list;

using (SqlConnection _conn = new SqlConnection(_con))
{
Expand All @@ -609,7 +613,9 @@ select su.name FROM [{0}]..sysusers as su
inner JOIN master..syslogins as sl on su.sid = sl.sid
where su.hasdbaccess = 1 AND su.islogin = 1 AND su.issqluser = 1 AND su.name <> 'dbo'",
dbitem.Name), _conn))
{
{
//MessageBox.Show(_cmd.CommandText);

using (SqlDataReader _read = _cmd.ExecuteReader())
{
while (_read.Read())
Expand Down Expand Up @@ -1031,21 +1037,21 @@ private string GetPhysicalPathByDomainName(string siteName)
private bool isWebSiteExists()
{
using (ServerManager _server = new ServerManager())
{
{
return _server.Sites.Where(m => m.Name == WEBSITEPANEL_WEBSITE_NAME).Any();
}
}

public void SetCryptoKey()
{
//WebSitePanel Parolaları Endoce edilmiş mi?
if (isWebSiteExists())
{
//if (isWebSiteExists())
//{
System.Configuration.Configuration rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/", WEBSITEPANEL_WEBSITE_NAME);

CryptoKey = rootWebConfig1.AppSettings.Settings["WebsitePanel.CryptoKey"].Value;
EncryptionEnabled = ConfigurationManager.AppSettings["WebsitePanel.EncryptionEnabled"] != null ? Boolean.Parse(ConfigurationManager.AppSettings["WebsitePanel.EncryptionEnabled"]) : true;
}
//}
}

private string userNameFix(string username)
Expand All @@ -1055,8 +1061,28 @@ private string userNameFix(string username)

return username;
}
}

private bool isDatabaseExists(string databaseName)
{
var result = false;

using (SqlConnection _conn = new SqlConnection(connectionString))
{
_conn.Open();

using (SqlCommand _cmd = new SqlCommand(String.Format(@"SELECT name FROM master.sys.databases WHERE name = '{0}'", databaseName), _conn))
{
result = _cmd.ExecuteNonQuery() > 0 ? true: false;
}

_conn.Close();
}

return result;
}

}

public struct DataBaseItem
{
public int Id { get; set; }
Expand Down
1 change: 1 addition & 0 deletions MpMigrate.Data/Entity/Domain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public Domain()
Emails = new List<Email>();
Limits = new HostLimit();
Expiration = DateTime.Now.AddYears(1).Date;
Databases = new List<Database>();
Zone = new DnsZone();
}

Expand Down
22 changes: 16 additions & 6 deletions MpMigrate/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ private void _migrate_Action(MigrateManager m, ApiAction e)
{
this.UIThread(delegate
{
if (e == null)
return;

progressBarFinish.Value = e.Count > progressBarFinish.Maximum ? progressBarFinish.Maximum : e.Count;

labelFinisDomain.Text = e.DomainName;
Expand Down Expand Up @@ -483,27 +486,34 @@ private void stepFinishPage_Commit(object sender, AeroWizard.WizardPageConfirmEv
SetProgressBar();

if (!executeTask.IsCompleted && !executeTask.IsCanceled && !executeTask.IsFaulted)
{
{
executeTask.Start();
executeTask.ContinueWith((t) =>
executeTask.ContinueWith((t) =>
{
MessageBox.Show("Operation Completed","", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (t.Exception != null)
{
var logMessage = String.Format("{0},{1}", t.Exception.Message, t.Exception.StackTrace);
System.Diagnostics.EventLog.WriteEntry("MaestroPanel", logMessage);
MessageBox.Show(logMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
foreach (var item in t.Exception.InnerExceptions)
{
MessageBox.Show(item.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
logMessage = String.Format("{0},{1}", item.Message, item.StackTrace);
System.Diagnostics.EventLog.WriteEntry("MaestroPanel", logMessage);
MessageBox.Show(logMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
buttonShowLogs.Enabled = true;
MessageBox.Show(String.Format("Operation Completed:{0}", executeTask.Status.ToString()), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}, TaskContinuationOptions.OnlyOnFaulted);
}
else
{
MessageBox.Show("Migration already start. Please wait.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show("Migration already start. Please wait.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

Expand Down

0 comments on commit 7093112

Please sign in to comment.