public static void Main(string[] args) { //DataStorage DB = DataStorage.Instance; //bool status = false; //status = DB.PhoneBooks.FixBrokenContacts(); //status = status && true; AdLib ad = new AdLib(); AdUserInfo userInfo = ad.GetUserAttributes("*****@*****.**"); //string result = string.Empty; //result = DB.NumberingPlans.GetTypeOfServiceByNumber("+962795797572"); //result = result + ""; //var users_summaries = DB.UsersCallsSummaries.GetBySipAccount("*****@*****.**", startDate, endDate); //users_summaries = DB.UsersCallsSummaries.GetBySite("MOA", startDate, endDate, Globals.CallsSummary.GroupBy.UserAndInvoiceFlag); //users_summaries = DB.UsersCallsSummaries.GetByGateway("10.1.1.3"); //var first_user_summary = summaries.First(); //var sites_summaries = DB.SitesCallsSummaries.GetBySite("MOA", startDate, endDate); //var yearsForAAlhour = DB.UsersCallsSummaries.GetYearsBySipAccount("*****@*****.**"); //var siteSummaries = DB.SitesCallsSummaries.GetBySite("MOA"); //siteSummaries = DB.SitesCallsSummaries.GetBySite("MOA", startDate, endDate); //var departmensSummaries = DB.DepartmensCallsSummaries.GetByDepartment("MOA", "ISD"); //var departmentTotal = DB.DepartmensCallsSummaries.GetTotalByDepartment("MOA", "ISD"); //var siteDepartmensTotals = DB.DepartmensCallsSummaries.GetTotalsForEachDepartmentInSite("MOA"); //var MOA_Gateways_Summaries = DB.GatewaysCallsSummaries.GetBySite("MOA", groupBy: Globals.CallsSummaryForGateway.GroupBy.GatewayNameOnly); //var MOA_101012_Summaries = DB.GatewaysCallsSummaries.GetBySiteAndGateway("MOA", "10.1.0.12"); //var Gateways_Usage = DB.GatewaysCallsSummaries.GetUsageForAllGateways(startDate, endDate); //var Usage_Stats = DB.GatewaysCallsSummaries.GetGatewaysStatisticsResults(Gateways_Usage); //var topNumbers = DB.TopDestinationNumbers.GetBySipAccount("*****@*****.**", 10); //var topCountriesForUser = DB.TopDestinationCountries.GetByUser("*****@*****.**", 10); //var topCountriesForDepartment = DB.TopDestinationCountries.GetByDepartment("MOA", "ISD", 10); //var topCountriesForSite = DB.TopDestinationCountries.GetBySite("MOA", 10); //var mailReportsForUser = DB.MailReports.GetByUser("*****@*****.**", (new DateTime(2013, 10, 1))); //var mailReportForUser = DB.MailReports.GetTotalByUser("*****@*****.**", (new DateTime(2013, 10, 1))); //var mailReportForDepartment = DB.MailReports.GetByDepartment("MOA", "ISD", (new DateTime(2013, 10, 1))); //var userChartReports = DB.ChartsReports.GetByUser("*****@*****.**"); //var departmentChartReports = DB.ChartsReports.GetByDepartment("MOA", "ISD"); //var siteChartsReports = DB.ChartsReports.GetBySite("MOA"); //var gatewayChartsReports = DB.ChartsReports.GetByGateway("MOA", "10.1.0.12"); }
protected void LogIn(object sender, EventArgs e) { UserSession session = new UserSession(); AdUserInfo userInfo = new AdUserInfo(); List <SystemRole> userSystemRoles = new List <SystemRole>(); LyncBillingBase.DataModels.User existingiBillUser; LyncBillingBase.DataModels.User iBillUser = new LyncBillingBase.DataModels.User(); //START bool status = false; string msg = string.Empty; if (IsValid) { status = ADConnector.AuthenticateUser(Email.Text, Password.Text, out msg); AuthenticationMessage = msg; // Impersonation example // email.Text = "*****@*****.**"; // status = true; if (status == true) { userInfo = ADConnector.GetUserAttributes(Email.Text); // Users Information was found in active directory if (userInfo != null && !string.IsNullOrEmpty(userInfo.SipAccount)) { //Try to get user from the database existingiBillUser = Global.DATABASE.Users.GetBySipAccount(userInfo.SipAccount.Replace("sip:", "")); //Update the user, if exists and if his/her info has changed... Insert te Users if s/he doesn't exist if (existingiBillUser != null) { //Make sure the user record was updated by ActiveDirectory and not by the System Admin //If the system admin has updated this user then you cannot update his record from Active Directory if (existingiBillUser.UpdatedByAd == Convert.ToByte(true)) { //If user information from Active directory doesnt match the one in Users Table : update user table if (existingiBillUser.EmployeeId.ToString() != userInfo.EmployeeId || existingiBillUser.FullName != String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName) || existingiBillUser.SiteName != userInfo.PhysicalDeliveryOfficeName || existingiBillUser.DepartmentName != userInfo.department || existingiBillUser.TelephoneNumber != HelperFunctions.FormatUserTelephoneNumber(userInfo.Telephone)) { int employeeID = 0; // Validate employeeID if it could be parsed as integer or not bool result = Int32.TryParse(userInfo.EmployeeId, out employeeID); if (result) { iBillUser.EmployeeId = employeeID; } else { iBillUser.EmployeeId = 0; } iBillUser.SipAccount = userInfo.SipAccount.Replace("sip:", ""); iBillUser.FullName = String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName); iBillUser.TelephoneNumber = HelperFunctions.FormatUserTelephoneNumber(userInfo.Telephone); iBillUser.DepartmentName = userInfo.department; iBillUser.SiteName = userInfo.PhysicalDeliveryOfficeName; iBillUser.UpdatedByAd = Convert.ToByte(true); Global.DATABASE.Users.Update(iBillUser); } } } else { // If user not found in Users tables that means this is his first login : insert his information into Users table int employeeID = 0; bool result = Int32.TryParse(userInfo.EmployeeId, out employeeID); if (result) { iBillUser.EmployeeId = employeeID; } else { iBillUser.EmployeeId = 0; } iBillUser.SipAccount = userInfo.SipAccount.Replace("sip:", ""); iBillUser.FullName = String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName); iBillUser.TelephoneNumber = HelperFunctions.FormatUserTelephoneNumber(userInfo.Telephone); iBillUser.DepartmentName = userInfo.department; iBillUser.SiteName = userInfo.PhysicalDeliveryOfficeName; iBillUser.UpdatedByAd = Convert.ToByte(true); Global.DATABASE.Users.Insert(iBillUser); } // //Assign the current userInfo to the UserSession fields. SetUserSessionFields(ref session, userInfo); // // Encrypt the password and assign it to the session session.EncryptedPassword = Global.ENCRYPTION.EncryptRijndael(Password.Text); Session.Add("UserData", session); if (this.RedirectToUrl != null && !string.IsNullOrEmpty(this.RedirectToUrl.Value)) { Response.Redirect(this.RedirectToUrl.Value); } else { Response.Redirect(String.Format(@"{0}/User/Dashboard", Global.APPLICATION_URL)); } }//end-if-userInfo-noteq-null else { AuthenticationMessage = "Invalid ActiveDirectory Account."; } }//end-if-status-is-true if (AuthenticationMessage.ToString() != string.Empty) { AuthenticationMessage = "* " + AuthenticationMessage; } } //end-if-valid } //end-function