public static decimal ToPreferedWeightUnit(this decimal amount, string unit = "MT") { string currentUnit; // Get current unit setting for the user. // NOTE: Since we might call this method from public views where we might not have a signed-in // user, we must check for possible errors. try { var user = UserAccountHelper.GetCurrentUser(); currentUnit = user.PreferedWeightMeasurment; } catch (Exception) { currentUnit = unit; } // If the current unit is 'Metric Tone' then return the value (the passed value) if (currentUnit.ToUpper().Trim() == "MT") { return(amount); } // For the other unit (quintal) multiply by 10 return(amount * 10); }
public static float GetPreferedRation1(this decimal amount) { string currentUnit; try { var user = UserAccountHelper.GetCurrentUser(); currentUnit = user.PreferedWeightMeasurment; } catch (Exception) { return((float)amount); } if (currentUnit.ToUpper().Trim() == "MT") { return((float)(amount / 1000)); } return((float)(amount / 100)); }
public static string AmharicReportList() { var html = string.Empty; var userName = System.Configuration.ConfigurationManager.AppSettings["CatsReportUserName"]; var password = System.Configuration.ConfigurationManager.AppSettings["CatsReportPassword"]; var user = (UserIdentity)HttpContext.Current.User.Identity; var role = UserRoleHelper.GetUserRole(user.Profile.UserName); var lang = user.Profile.LanguageCode; var currentUser = UserAccountHelper.GetCurrentUser(); try { var rs = new ReportingService2010 { Credentials = new NetworkCredential(userName, password) }; //var folders = rs.ListChildren("/", false); ////html += "<ul class='dropdown-menu'>"; //foreach (var folder in folders) //{ //if (folder.TypeName == "Folder" && folder.Name != "Data Sources" && folder.Name != "Datasets") //{ var reports = new CatalogItem[100]; if (currentUser.RegionalUser) { reports = rs.ListChildren("/Regional/AM", false); } else if (currentUser.DefaultHub != null) { reports = rs.ListChildren("/Hub/AM", false); } else if (currentUser.CaseTeam != null) { switch (currentUser.CaseTeam) { case (int)UserType.CASETEAM.EARLYWARNING: reports = rs.ListChildren("/Early Warning/AM", false); break; case (int)UserType.CASETEAM.PSNP: reports = rs.ListChildren("/FSCD/AM", false); break; case (int)UserType.CASETEAM.LOGISTICS: reports = rs.ListChildren("/Logistics/AM", false); break; case (int)UserType.CASETEAM.PROCUREMENT: reports = rs.ListChildren("/Procurement/AM", false); break; case (int)UserType.CASETEAM.FINANCE: reports = rs.ListChildren("/Finance/AM", false); break; } } //html += "<li class='dropdown-submenu'>"; //html += "<a href='#' data-toggle='dropdown'>" + folder.Name + "</a>"; //html += "<ul class='dropdown-menu'>"; //html += "<div> <table class='table table-bordered'> <thead> <tr> <th>Report</th> <th>Description</th> </tr> </thead> <tbody>"; //html += "<div id='list8'><ul>"; html += "<div> <ul>"; foreach (var report in reports) { html += "<li>"; var baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/"; html += "<a class='AMreportLink' data-toggle='tooltip' data-placement='bottom' rel='tooltip' title='" + report.Description + "' data-reportpath='" + report.Path + "' href=' " + baseUrl + "AmharicReportViewer.aspx?path=" + report.Path + "'>" + report.Name + "</a>"; //var desc = report.Description; html += "</li>"; } html += "</ul></div>"; //html += "</tbody> </table> </div>"; //} //} //html += "</ul>"; } catch (Exception ex) { html = ""; } return(html); }