private bool IsCurrentUserAdimn(Durados.View view, DataRow row) { if (row.IsNull("Id") || string.IsNullOrEmpty(row["Id"].ToString())) { throw new DuradosException("Application missing Id. Cannot determine if user is admin."); } int appId; if (!int.TryParse(row["Id"].ToString(), out appId)) { throw new DuradosException("Application Id can not be parsed"); } string userId = ((Database)view.Database).GetUserID(); if (userAppsAdminIds == null) { LoadUserAdminApps(userId); } if (userAppsAdminIds != null && userAppsAdminIds.Contains(appId)) { return(true); } else { return(false); } }
public Dictionary <string, string> GetUserApps() { int rowCount = 0; Dictionary <string, object> values = new Dictionary <string, object>(); Durados.View appsView = Database.Views["durados_App"]; DataView dataView = null; try { dataView = appsView.FillPage(1, 10000, values, null, null, out rowCount, null, null); } catch (Exception) { AddSslAndAahKeyColumn(); dataView = appsView.FillPage(1, 10000, values, null, null, out rowCount, null, null); } AddSslAndAahKeyColumnConfig(); Dictionary <string, string> apps = new Dictionary <string, string>(); foreach (System.Data.DataRowView row in dataView) { apps.Add(row["Id"].ToString(), row["Title"].ToString()); } return(apps); }
protected bool IsActiveConfiguration(Durados.View view, object data) { if (view != null && !view.Fields.ContainsKey("Active")) { throw new DuradosException("Missing Active Config Field."); } if (data != null && !(data is DataRow)) { throw new DuradosException("Missing data row for xml document file name."); } Durados.Field field = view.Fields["Active"]; string activeConfig = field.GetValue((DataRow)data); bool isActiveConfig = false;; //string outputXmlFileName = newFile; if (!string.IsNullOrEmpty(activeConfig) && field is ColumnField && bool.TryParse(((ColumnField)field).ConvertFromString(activeConfig).ToString(), out isActiveConfig)) { return(isActiveConfig); } else { return(false); } }
protected override System.Data.IDbConnection GetConnection(Durados.View view) { if (view.SystemView) { return(new System.Data.SqlClient.SqlConnection(view.ConnectionString)); } switch (view.Database.SqlProduct) { case SqlProduct.MySql: return(new MySql.Data.MySqlClient.MySqlConnection(view.ConnectionString)); case SqlProduct.Postgre: Npgsql.NpgsqlConnection connection = new Npgsql.NpgsqlConnection(view.ConnectionString); connection.ValidateRemoteCertificateCallback += new Npgsql.ValidateRemoteCertificateCallback(connection_ValidateRemoteCertificateCallback); return(connection); case SqlProduct.Oracle: return(new Oracle.ManagedDataAccess.Client.OracleConnection(view.ConnectionString)); case SqlProduct.SqlServer: case SqlProduct.SqlAzure: return(new System.Data.SqlClient.SqlConnection(view.ConnectionString)); default: return(base.GetConnection(view)); } }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if ((new string[5] { "Issue", "Project", "User", "TimeSheet", "MonthlyProjectHoursReport" }).Contains(view.Name)) { if (User.IsInRole("User")) { if (User == null || User.Identity == null || User.Identity.Name == null) { throw new AccessViolationException(); } int?companyID = Durados.Web.Mvc.Specifics.DataAccess.User.GetCompanyID(User.Identity.Name); if (!companyID.HasValue) { throw new AccessViolationException(); } sql += " where CompanyID = " + companyID.Value; } } }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if (view.Name == CRMViews.CountryType.ToString()) { sql += " where Active = 1"; } }
//protected override Category GetCategory() //{ // if (ChildrenHtmlControlType == ChildrenHtmlControlType.Grid && category == null) // { // return new Category() { Name = DisplayName, Ordinal = 100 }; // } // else // { // return base.GetCategory(); // } //} public override Dictionary <string, string> GetAutocompleteValues(string q, int limit) { Durados.ParentField parentField = null; Durados.ParentField fkField = null; Durados.View otherParentView = GetOtherParentView(out parentField, out fkField); return(((ParentField)parentField).GetSelectOptions(q, AutocompleteMathing == AutocompleteMathing.StartsWith, limit, null)); }
private bool IsCurrentUserCreator(Durados.View view, DataRow row) { bool isCreator; isCreator = !row.IsNull("Creator") && row["Creator"].ToString().Equals(((Database)view.Database).GetUserID()); return(isCreator); }
public override string GetEditTitle(Durados.View view, DataRow row) { if (row["Creator"].Equals(((Database)view.Database).GetUserID())) { return(base.GetEditTitle(view, row)); } else { return(Maps.Instance.GetMap().Database.Localizer.Translate("View current record")); } }
public override string GetEditCaption(Durados.View view, DataRow row, string guid) { if (IsCurrentUserCreator(view, row) || IsCurrentUserAdimn(view, row)) { return(base.GetEditCaption(view, row, guid)); } else { return(Maps.Instance.GetMap().Database.Localizer.Translate("View")); } }
public virtual void SaveMessageAction(Durados.View view, string pk, object value, int messageBoardAction, int userId) { SqlAccess sqlAccess = new SqlAccess(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@UserId", userId); parameters.Add("@MessageId", Convert.ToInt32(pk)); parameters.Add("@ActionId", messageBoardAction); parameters.Add("@ActionValue", value); sqlAccess.ExecuteProcedure(Map.Database.SysDbConnectionString, "Durados_MessageBoard_Action", parameters, null); }
private string[] GetIssueCc(Durados.View view, Dictionary <string, object> values, string pk, Durados.Workflow.EmailParameters emailParameters) { string reportedUserEmail = GetUserEmail(view, pk); string[] cc = emailParameters.Cc; List <string> ccList = new List <string>(cc); ccList.Add(reportedUserEmail); return(ccList.ToArray()); }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if (Durados.Web.Mvc.UI.Helpers.SecurityHelper.IsInRole("User") && view.Name == "User") { if (User == null || User.Identity == null || User.Identity.Name == null) { throw new AccessViolationException(); } sql += " where Username = N'" + User.Identity.Name + "'"; } }
public virtual bool IsParametersChanged(Durados.View view, OldNewValue[] oldNewValues) { foreach (OldNewValue oldNewValue in oldNewValues) { if (view.Fields.ContainsKey(oldNewValue.FieldName)) { Field field = view.Fields[oldNewValue.FieldName]; if (field.Category != null && field.Category.Name.ToLower().Contains("parameter")) { return(true); } } } return(false); }
/// <summary> /// Get select options for filter field /// </summary> /// <param name="field"></param> /// <param name="fk"></param> /// <param name="top"></param> /// <returns></returns> public static Dictionary <string, string> GetSelectOptions(this Field field, string fk, int?top, bool forFilter) { ParentField parentField = field.GetParentField(); Durados.View view = null; if (field != null && field.FieldType == FieldType.Children) { view = field.View; } else if (parentField != null) { view = parentField.View; } return(GetSelectOptions(parentField, view as Durados.Web.Mvc.View, fk, top, forFilter)); }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { base.DropDownFilter(parentField, ref sql); Durados.View view = parentField.ParentView; if (view.Name == "Issue") { if (sql.ToLower().Contains("where")) { sql += " and [Issue].[TimeEstimate] > 0"; } else { sql += "where [Issue].[TimeEstimate] > 0"; } } }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if ((new string[1] { "A_111" }).Contains(view.Name)) { if (User.IsInRole("User")) { if (User == null || User.Identity == null || User.Identity.Name == null) { throw new AccessViolationException(); } sql += " where sochen_1 = N'" + User.Identity.Name + "'"; } } }
public virtual bool HasParametersChanged(Durados.View view, DataRow dataRow, Dictionary <string, object> values) { foreach (KeyValuePair <string, object> value in values) { Field field = view.Fields[value.Key]; if (field != null) { string drVal = field.GetValue(dataRow); string valVal = (value.Value ?? string.Empty).ToString(); if (!string.IsNullOrEmpty(valVal) || !string.IsNullOrEmpty(drVal)) { if ((!string.IsNullOrEmpty(valVal) && string.IsNullOrEmpty(drVal)) || (string.IsNullOrEmpty(valVal) && !string.IsNullOrEmpty(drVal)) || drVal != valVal) { return(true); } } } } return(false); }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if ((new string[6] { "Issue", "Project", "User", "TimeSheet", "MonthlyProjectHoursReport", "Company" }).Contains(view.Name)) { if (Durados.Web.Mvc.UI.Helpers.SecurityHelper.IsInRole("User")) { if (User == null || User.Identity == null || User.Identity.Name == null) { throw new AccessViolationException(); } int?companyID = DataAccess.User.GetCompanyID(User.Identity.Name); if (!companyID.HasValue) { throw new AccessViolationException(); } if (view.Name == "Company") { sql += " where ID = " + companyID.Value; } else if (sql.IndexOf("CompanyID") < 0) { if (sql.ToLower().Contains("where")) { sql += " and CompanyID = " + companyID.Value; } else { sql += " where CompanyID = " + companyID.Value; } } } } }
protected ISqlTextBuilder GetSqlTextBuilder(Durados.View view) { if (view.SystemView) { return(new SqlTextBuilder()); } switch (view.Database.SqlProduct) { case SqlProduct.MySql: return(new Durados.DataAccess.MySqlTextBuilder()); case SqlProduct.Postgre: return(new Durados.DataAccess.PostgreTextBuilder()); case SqlProduct.Oracle: return(new Durados.DataAccess.OracleTextBuilder()); default: return(new SqlTextBuilder()); } }
private string GetConfigFileExists(Durados.View view, string documentFieldName, string filename, string pk) { object scalar = null; FileInfo fileinfo = new FileInfo(filename); string sql = string.Format("select id from [{0}] where {1} = '{2}' and id <> {3}", view.Name, documentFieldName, fileinfo.Name, pk); using (SqlConnection connection = new SqlConnection(view.Database.ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { scalar = command.ExecuteScalar(); } } if (scalar == null || scalar == DBNull.Value) { return(null); } else { return(scalar.ToString()); } }
public virtual string SaveInMessageBoard(Dictionary <string, Durados.Parameter> parameters, Durados.View view, Dictionary <string, object> values, System.Data.DataRow prevRow, string pk, string siteWithoutQueryString, string urlAction, string subject, string message, int currentUserId, string currentUserRole, Dictionary <int, bool> recipients) { return(SaveInMessageBoard(parameters, (View)view, values, prevRow, pk, siteWithoutQueryString, urlAction, subject, message, currentUserId, recipients)); }
public string GetUrlAction(Durados.View view, string pk) { //return Url.Action(((View)view).IndexAction, ((View)view).Controller, new { viewName = view.Name, pk = pk }); return(string.Empty); }
public string[] GetFilterFieldValue(Durados.View view) { return(null); }
public void LoadValue(Dictionary <string, object> values, System.Data.DataRow dataRow, Durados.View view, Durados.Field field, string dynastyPath, string prefix, string postfix, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath) { string name = prefix + dynastyPath + field.DisplayName + postfix; string InternalName = prefix + internalDynastyPath + field.Name + postfix; string value = view.GetDisplayValue(field.Name, dataRow); if (!values.ContainsKey(name)) { values.Add(name, value); dicFields.Add(InternalName, new Durados.Workflow.DictionaryField { DisplayName = name, Type = field.DataType, Value = value }); } if (field.FieldType == Durados.FieldType.Column && ((ColumnField)field).Upload != null) { if (dataRow.Table.Columns.Contains(field.Name)) { dataRow.Table.Columns[field.Name].ExtendedProperties["ImagePath"] = ((ColumnField)field).GetUploadPath(); } } }
public void LoadValues(Dictionary <string, object> values, System.Data.DataRow dataRow, Durados.View view, Durados.ParentField parentField, Durados.View rootView, string dynastyPath, string prefix, string postfix, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath) { if (view.Equals(rootView)) { dynastyPath = GetViewDisplayName((View)view) + "."; internalDynastyPath = view.Name + "."; } foreach (Durados.Field field in view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Column)) { LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath); } var childrenFields = view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Children && ((ChildrenField)f).LoadForBlockTemplate); foreach (ChildrenField field in childrenFields) { string name = prefix + dynastyPath + field.DisplayName + postfix; string internalName = prefix + internalDynastyPath + field.Name + postfix; System.Data.DataView value = GetDataView(field, dataRow); if (!values.ContainsKey(name)) { values.Add(name, value); dicFields.Add(internalDynastyPath, new Durados.Workflow.DictionaryField { DisplayName = field.DisplayName, Type = field.DataType, Value = value }); } foreach (ColumnField columnField in field.ChildrenView.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Column)) { if (columnField.Upload != null) { value.Table.Columns[columnField.Name].ExtendedProperties["ImagePath"] = columnField.GetUploadPath(); } } } foreach (ParentField field in view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Parent)) { if (view.Equals(rootView)) { dynastyPath = view.DisplayName + "."; internalDynastyPath = view.Name + "."; } LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath); System.Data.DataRow parentRow = null; View parentView = null; if (dataRow != null) { parentRow = dataRow.GetParentRow(field.DataRelation.RelationName); parentView = (View)field.ParentView; if (parentRow == null) { string key = field.GetValue(dataRow); if (!string.IsNullOrEmpty(key)) { parentRow = parentView.GetDataRow(key, dataRow.Table.DataSet); } } } if (parentRow != null && parentField != field) { if (parentView != rootView) { //dynastyPath += field.DisplayName + "."; dynastyPath = GetDynastyPath(dynastyPath, (ParentField)parentField, field); internalDynastyPath = GetInternalDynastyPath(internalDynastyPath, (ParentField)parentField, field); LoadValues(values, parentRow, parentView, field, rootView, dynastyPath, prefix, postfix, dicFields, internalDynastyPath); } } } }
private string GetUserEmail(Durados.View view, string pk) { return(((Durados.Web.Mvc.Database)view.Database).GetUserRow()["Email"].ToString()); }
protected override Durados.Workflow.EmailParameters GetEmailParameters(object controller, Dictionary <string, Parameter> parameters, Durados.View view, Dictionary <string, object> values, DataRow prevRow, string pk, string siteWithoutQueryString, string connectionString) { Durados.Workflow.EmailParameters emailParameters = base.GetEmailParameters(controller, parameters, view, values, prevRow, pk, siteWithoutQueryString, connectionString); if (view.Name == "Issue") { int?uReport = null; int id = Int32.Parse(pk); if (values.ContainsKey("FK_Issue_User_Report_Parent")) { if (values["FK_Issue_User_Report_Parent"] != null && values["FK_Issue_User_Report_Parent"].ToString() != "") { uReport = int.Parse(values["FK_Issue_User_Report_Parent"].ToString()); } } else { uReport = Durados.Web.Mvc.Specifics.Bugit.DataAccess.Issue.GetReportedBy(id); } if (uReport.HasValue) { emailParameters.To = GetEmails(emailParameters.Cc, uReport.Value); } int?uAssign = null; if (values.ContainsKey("FK_Issue_User_Assign_Parent")) { if (values["FK_Issue_User_Assign_Parent"] != null && values["FK_Issue_User_Assign_Parent"].ToString() != "") { uAssign = int.Parse(values["FK_Issue_User_Assign_Parent"].ToString()); } } else { uAssign = Durados.Web.Mvc.Specifics.Bugit.DataAccess.Issue.GetAssignedTo(id); } if (uAssign.HasValue) { emailParameters.To = GetEmails(emailParameters.To, uAssign.Value); } } return(emailParameters); }
public CapabilitiesConfigComparer(Durados.View view) { this.View = view; }
public CapabilitiesParamModeComparer(Durados.View view) : base(view) { }