public static string ReplaceWithDollar(this string template, Durados.View view, Dictionary <string, object> nameValueDictionary) { if (nameValueDictionary == null) { return(template); } string content = template; foreach (string name in nameValueDictionary.Keys) { object value = nameValueDictionary[name]; if (value is string) { string s; if (view.Fields.ContainsKey(name) && view.Fields[name].FieldType == Durados.FieldType.Column && view.Fields[name].GetColumnFieldType() == Durados.ColumnFieldType.Boolean && value.Equals(string.Empty)) { s = "False"; } else { s = value.ToString(); } content = content.ReplaceDictionaryTokens("$", name, s); } else if (value != null) { content = content.ReplaceDictionaryTokens("$", name, value.ToString()); } } return(content); }
protected virtual DataSet CreateXmlDataset(string template, object data, Durados.View view) { DataRow row = (DataRow)data; Durados.Xml.Schema.Converter converter = GetXmlConverter(); return(converter.Convert(view, row, template)); }
private void ValidateVia(Fk fk) { if (!Map.Database.Views.ContainsKey(fk.ParentTable)) { return; } Durados.View parentView = Map.Database.Views[fk.ParentTable]; if (!Map.Database.Views.ContainsKey(fk.ChildTable)) { return; } Durados.View childView = Map.Database.Views[fk.ChildTable]; if (parentView.DataTable.Columns.Contains(fk.ParentColumn) || parentView.Fields.ContainsKey(fk.ParentColumn)) { throw new NewFkException(fk.ParentTable, fk.ParentColumn); } if (childView.DataTable.Columns.Contains(fk.ChildColumn) || childView.Fields.ContainsKey(fk.ChildColumn)) { throw new NewFkException(fk.ChildTable, fk.ChildColumn); } }
public virtual Durados.View GetApprovalProcessView(Durados.View view) { if (!Database.Views.ContainsKey("durados_ApprovalProcess")) { throw new Durados.Workflow.WorkflowEngineException("Colud not found the view durados_ApprovalProcess in the database."); } return(Database.Views["durados_ApprovalProcess"]); }
public static string Replace(this string template, Dictionary <string, object> nameValueDictionary, ITableConverter tableConverter, Durados.View view) { if (nameValueDictionary == null) { return(template); } AdjustToShortDictionary(nameValueDictionary); string content = template; foreach (string name in nameValueDictionary.Keys) { if (!name.IsToken()) { continue; } object value = nameValueDictionary[name]; if (value is string) { content = content.ReplaceToken(name, value.ToString()); } else if (value == null) { content = content.ReplaceToken(name, string.Empty); } else if (value is DataView) { if (tableConverter == null || view == null) { content = content.ReplaceToken(name, string.Empty); } else { if (content.Contains(name)) { Durados.View childrenView = GetChildrenView(view, name); if (childrenView != null) { content = content.ReplaceToken(name, tableConverter.Convert(childrenView, (DataView)value, nameValueDictionary)); } else { content = content.ReplaceToken(name, value.ToString()); } } } } else { content = content.ReplaceToken(name, value.ToString()); } } return(content); }
public virtual string Convert(Durados.View view, DataView dataView, Dictionary <string, object> nameValueDictionary) { StringBuilder grid = new StringBuilder(); grid.Append("<table class='grid' border=0 cellspacing=0 cellpadding=0>"); List <Durados.Field> fields = ((View)view).VisibleFieldsForTableFirstRow; grid.Append("<tr>"); foreach (Durados.Field field in fields) { grid.Append("<th>"); grid.Append(field.DisplayName); grid.Append("</th>"); } grid.Append("</tr>"); foreach (System.Data.DataRowView row in dataView) { grid.Append("<tr>"); foreach (Durados.Field field in fields) { grid.Append("<td>"); if (field.FieldType == FieldType.Column && ((ColumnField)field).DataColumn.DataType.Equals(typeof(bool))) { if (row.Row.IsNull(((ColumnField)field).DataColumn.ColumnName)) { grid.Append(string.Empty); } else { grid.Append(row.Row[((ColumnField)field).DataColumn.ColumnName].ToString()); } } else { grid.Append(GetElementForTableView(field, row.Row, null)); } grid.Append("</td>"); } grid.Append("</tr>"); } grid.Append("</table>"); return(grid.ToString()); }
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); }
//public static string ReplaceGlobals(this string template, View view) //{ // return ReplaceGlobals(template, view.Database); //} //public static string ReplaceGlobals(this string template, Database database) //{ // string s = template; // try // { // foreach (int key in database.Globals.Keys) // { // string name = database.Globals[key].Name; // string value = database.Globals[key].Value; // s = s.Replace((Database.SysPlaceHolder + name).AsToken(), value); // } // } // catch { } // return s; //} private static Durados.View GetChildrenView(Durados.View view, string name) { name = name.TrimStart('[').TrimEnd(']'); string[] names = name.Split('.'); if (names.Length <= 1) { return(null); } Durados.View root = view.Database.GetView(names[0]); if (root == null) { return(null); } Durados.View parentView = root; Durados.Field[] fields = null; Durados.Field field = null; for (int i = 1; i < names.Length - 1; i++) { fields = parentView.GetFieldsByDisplayName(names[i]); if (fields == null || fields.Length != 1) { return(null); } field = fields[0]; if (field.FieldType != Durados.FieldType.Parent) { return(null); } parentView = ((Durados.ParentField)field).ParentView; } fields = parentView.GetFieldsByDisplayName(names[names.Length - 1]); if (fields == null || fields.Length != 1) { return(null); } field = fields[0]; if (field.FieldType != Durados.FieldType.Children) { return(null); } return(((Durados.ChildrenField)field).ChildrenView); }
public void UpdateDocumentRow(Durados.View view, string id, string fieldName, string filename, System.Data.IDbCommand command) { Map map = Maps.Instance.GetMap(); SqlSchema sqlSchema = new SqlSchema(); using (IDbConnection connection = sqlSchema.GetConnection(map.systemConnectionString)) { IDbCommand sysCommand = new System.Data.SqlClient.SqlCommand(); sysCommand.Connection = connection; connection.Open(); UpdateDocumentRow((View)view, id, fieldName, filename, command, sysCommand); } }
public virtual string GetRowHeightStyle(Durados.View view) { string viewHeight = view.RowHeight; if (string.IsNullOrEmpty(viewHeight)) { return(string.Empty); } else { return("line-height: " + viewHeight + "px; height:" + viewHeight + "px;"); } }
public virtual string GetFileName(Durados.View view, string documentFieldName, string fileName) { if (!view.Fields.ContainsKey(documentFieldName)) { throw new DuradosException("The view " + view.DisplayName + " does not contains the document field name " + documentFieldName); } ColumnField documentField = (ColumnField)view.Fields[documentFieldName]; string virtualPath = documentField.Upload.UploadVirtualPath; string path = HttpContext.Server.MapPath(virtualPath); return(path + fileName); }
public string Convert(Durados.View view, DataView dataView, Dictionary <string, object> nameValueDictionary) { string recipients = string.Empty; foreach (System.Data.DataRowView row in dataView) { foreach (Field field in view.Fields.Values.Where(f => f.FieldType == FieldType.Column && ((ColumnField)f).SpecialColumn == SpecialColumn.Email)) { recipients += field.ConvertToString(row.Row) + ";"; } } return(recipients.TrimEnd(';')); }
protected override void DropDownFilter(Durados.Web.Mvc.ParentField parentField, ref string sql) { Durados.View view = parentField.ParentView; if (User.IsInRole("User") && view.Name == "User") { if (User == null || User.Identity == null || User.Identity.Name == null) { throw new AccessViolationException(); } if (!sql.ToLower().Contains("where")) { sql += " where Username = N'" + User.Identity.Name + "'"; } } }
public static string Parse(this string formula, Durados.Field field, Durados.View view, Dictionary <string, Durados.Field> calcDynasty) { if (view == null) { view = field.View; } string formulaDetail = string.Empty; if (view == null || view.Fields == null) { throw new Durados.DuradosException("Could not parse calculted field, missing view or fields."); } if (field.IsCalculated && !string.IsNullOrEmpty(field.Formula)) { if (calcDynasty == null) { calcDynasty = new Dictionary <string, Durados.Field>(); } else { if (calcDynasty.ContainsKey(field.DatabaseNames)) { string strace = String.Join(",", calcDynasty.Keys.Select(o => o.ToString()).ToArray()); //calcDynasty.Keys.; throw new Durados.DuradosException("Calculted field cannot containe recursive call, check " + strace); //calcDynasty.Keys. } } calcDynasty.Add(field.DatabaseNames, field); formulaDetail = string.Format("({0})", field.Formula); foreach (Durados.Field f in view.Fields.Values.Where(r => (r.IsCalculated == true && r.DatabaseNames != field.DatabaseNames)).OrderBy(r => r.DatabaseNames.Length)) { string pattern = @"\b" + f.DatabaseNames + @"\b"; if ((Regex.Match(formulaDetail, pattern)).Success) { formulaDetail = formulaDetail.Replace(string.Format("[{0}]", f.DatabaseNames), f.DatabaseNames); Dictionary <string, Durados.Field> subTree = new Dictionary <string, Durados.Field>(calcDynasty); formulaDetail = string.Format("({0})", Regex.Replace(formulaDetail, pattern, f.Formula.Parse(f, view, subTree))); } } } return(formulaDetail); }
private void OrderViewAndColumns(Dictionary <string, object> transformResult) { ArrayList tables = (ArrayList)transformResult["tables"]; Dictionary <string, object> tableColumns = (Dictionary <string, object>)transformResult["columns"]; ConfigAccess ca = new ConfigAccess(); Durados.View viewView = map.GetConfigDatabase().Views["View"]; Durados.View fieldView = map.GetConfigDatabase().Views["Field"]; for (int i = 0; i < tables.Count; i++) { string viewJsonName = tables[i].ToString(); Durados.View view = Map.Database.GetViewByJsonName(viewJsonName); string viewName = view.Name; string vpk = ca.GetViewPK(viewJsonName, Map.GetConfigDatabase().ConnectionString); viewView.Edit(new Dictionary <string, object>() { { "Order", 10000 + i * 10 } }, vpk, view_BeforeEdit, view_BeforeEditInDatabase, view_AfterEditBeforeCommit, view_AfterEditAfterCommit); ArrayList columns = (ArrayList)tableColumns[viewJsonName]; for (int j = 0; j < columns.Count; j++) { string columnName = columns[j].ToString(); Field field = view.GetFieldByColumnNames(columnName); if (field != null) { string fieldName = field.Name; string fpk = ca.GetFieldPK(viewName, fieldName, Map.GetConfigDatabase().ConnectionString); fieldView.Edit(new Dictionary <string, object>() { { "Order", 500 + j * 10 } }, fpk, view_BeforeEdit, view_BeforeEditInDatabase, view_AfterEditBeforeCommit, view_AfterEditAfterCommit); } } } RefreshConfigCache(); }
public void LoadValue(Dictionary <string, object> values, 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 == FieldType.Column && ((ColumnField)field).Upload != null) { if (dataRow.Table.Columns.Contains(field.Name)) { dataRow.Table.Columns[field.Name].ExtendedProperties["ImagePath"] = ((ColumnField)field).GetUploadPath(); } } }
public static IDataTableAccess GetDataTableAccess(Durados.View view) { if (view is Durados.Config.IConfigView) { return(new ConfigAccess()); } else if (OracleAccess.IsOracleConnectionString(view.ConnectionString)) { return(new OracleAccess()); } if (PostgreAccess.IsPostgreConnectionString(view.ConnectionString)) { return(new PostgreAccess()); } else if (MySqlAccess.IsMySqlConnectionString(view.ConnectionString)) { return(new MySqlAccess()); } else { return(new SqlAccess()); } }
public override void CreateDocument(string newFile, object template, object data, Durados.Workflow.DocumentType documentType, Durados.View view) { CreateDocument2(newFile, (string)template, (Dictionary <string, object>)data); }
protected virtual void CreateXmlDocument(string newFile, Durados.Workflow.XmlTemplate template, object data, Durados.View view) { DataSet ds = CreateXmlDataset(template.Schema, data, view); ds.Namespace = null; ds.WriteXml(newFile); string outputFile = GetXmlDocumentName(newFile); TransformXml(newFile, template.Xslt, outputFile); template.Ouput = outputFile; }
public override void LoadValues(Dictionary <string, object> values, 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 (Field field in view.Fields.Values.Where(f => f.FieldType == FieldType.Column)) { LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath); } var childrenFields = view.Fields.Values.Where(f => f.FieldType == FieldType.Children && ((ChildrenField)f).LoadForBlockTemplate); foreach (ChildrenField field in childrenFields) { string name = prefix + dynastyPath + field.DisplayName + postfix; string internalName = prefix + internalDynastyPath + field.Name + postfix; 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 == 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 == FieldType.Parent)) { if (view.Equals(rootView)) { dynastyPath = view.DisplayName + "."; internalDynastyPath = view.Name + "."; } LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath); DataRow parentRow = dataRow.GetParentRow(field.DataRelation.RelationName); View 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); } } } }
public virtual string SaveInMessageBoard(Dictionary <string, Parameter> parameters, Durados.View view, Dictionary <string, object> values, 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 ActionResult Widget() { string id = GetIdFromParameters(); PlugInType plugInType = PlugInType; //string userId = GetUserID(); //if (string.IsNullOrEmpty(userId)) //{ // userId = Maps.Instance.DuradosMap.Database.CreatePlugInUser(id, plugInType, GetPlugInUserGuid()); //} //if (string.IsNullOrEmpty(userId)) // return RedirectToAction(EmptyWidgetActionName); DataRow instanceRow = Maps.Instance.DuradosMap.Database.GetSelectedInstanceRow(id, plugInType); if (instanceRow == null) { int?sampleAppId = null; if (string.IsNullOrEmpty(Request.QueryString[SampleAppIdInQueryString])) { sampleAppId = Maps.Instance.DuradosMap.Database.GetFirstSampleId(plugInType); } else { sampleAppId = (int?)Convert.ToInt32(Request.QueryString[SampleAppIdInQueryString]); } instanceRow = Maps.Instance.DuradosMap.Database.CreateSampleInstanceRow(id, plugInType, sampleAppId, GetPlugInUserId()); if (instanceRow == null) { new AppsGenerator().Generate(sampleAppId.Value, Maps.PlugInSampleGenerationCount); instanceRow = Maps.Instance.DuradosMap.Database.CreateSampleInstanceRow(id, plugInType, sampleAppId, GetPlugInUserId()); } if (instanceRow == null) { Exception exception = new DuradosException("Could not create sample instance"); Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "username: "******", id: " + this.Request.QueryString["id"], exception, 78, "url: " + System.Web.HttpContext.Current.Request.Url.ToString()); return(RedirectToAction(EmptyWidgetActionName)); } } //int appId = Maps.Instance.DuradosMap.Database.GetAppId(id, plugInType, instanceRow, userId); //(int)instanceRow["AppId"]; int appId = (int)instanceRow["AppId"]; string viewName = (string)instanceRow["ViewName"]; string appName = Maps.Instance.GetAppRow(appId).Name; if (string.IsNullOrEmpty(appName)) { Exception exception = new DuradosException("No app name for id:" + appId); Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "username: "******", id: " + this.Request.QueryString["id"], exception, 78, "url: " + System.Web.HttpContext.Current.Request.Url.ToString() + ", appName: " + appName + ", viewName: " + viewName); return(RedirectToAction(EmptyWidgetActionName)); } //bool isSampleApp = !instanceRow.IsNull("SampleAppId"); //string paremeters = string.Empty; //if (isSampleApp) //{ // string creatorGuid = GetCreatorGuid(appId); // paremeters = "&id=" + creatorGuid; //} Map map = Maps.Instance.GetMap(appName); if (!IsAuthorized(map)) { Exception exception = new DuradosException("Not authorized for app " + appName); Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "username: "******", id: " + this.Request.QueryString["id"], exception, 78, "url: " + System.Web.HttpContext.Current.Request.Url.ToString() + ", appName: " + appName + ", viewName: " + viewName); return(RedirectToAction(EmptyWidgetActionName)); } Durados.View view = map.Database.Views.ContainsKey(viewName) ? map.Database.Views[viewName] : null; if (view == null || !IsAuthorized(view)) { Exception exception = new DuradosException("Could not find view " + viewName + " check that configuration files exist"); Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "username: "******", id: " + this.Request.QueryString["id"], exception, 78, "url: " + System.Web.HttpContext.Current.Request.Url.ToString() + ", appName: " + appName + ", viewName: " + viewName); return(RedirectToAction(EmptyWidgetActionName)); } string url = GetViewUrl(map, viewName) + GetPublicParameter(); //string url = GetViewUrl(map, viewName) + GetUserIdParameterForLogin(instanceRow, appId) + GetPublicParameter(); //if (!IsSignedIn(Maps.Instance.DuradosMap.Database.GetCreatorUsername(appId))) //{ // SignOut(); // SignIn(Maps.Instance.DuradosMap.Database.GetCreatorUsername(appId)); // return Redirect(url); //} UpdatePlan(instanceRow); ViewData["url"] = url; ViewData["signOutUrl"] = Url.Action("SignOut") + "?" + GetParameters(); //map.Url + "/Account/LogOff"; Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), "username: "******", id: " + this.Request.QueryString["id"], null, 77, "url: " + System.Web.HttpContext.Current.Request.Url.ToString() + ", redirect: " + url + ", appName: " + appName + ", viewName: " + viewName); return(View()); //return Redirect(url); }
public virtual string GetFileName(string pk, string template, Dictionary <string, object> blocksValues, string documentFileNameKey, Durados.View view, Dictionary <string, object> values) { Workflow.Notifier notifier = new Durados.Web.Mvc.Workflow.Notifier(); return(notifier.GetMessage(this, documentFileNameKey, view, values, pk, GetSiteWithoutQueryString(), GetMainSiteWithoutQueryString())); }
public virtual string GetApprovalProcessStoredProcedureName(Durados.View view) { return("durados_CreateApprovalProcess"); }
public virtual string GetSubject(Durados.View view, string subjectKey, int id) { return(wfe.Notifier.GetSubject(this, subjectKey, view, null, id.ToString())); }
public virtual string GetMessage(Durados.View view, string messageKey, int id) { return(wfe.Notifier.GetMessage(this, messageKey, view, null, id.ToString(), GetSiteWithoutQueryString(), GetMainSiteWithoutQueryString())); }
public virtual string GetApprovalProcessSubjectKey(Durados.View view, string pk) { return("Approval Message"); }
public virtual Durados.ChildrenField GetApprovalProcessUsersChildrenField(Durados.View view) { return(null); }
protected virtual bool IsAuthorized(Durados.View view) { return(true); }
public virtual string GetTemplate(Durados.View view, string templateViewName, string templatePK, string documentFieldName, string templateViewFileNameFieldName) { return(GetTemplate((View)view, templateViewName, templatePK, documentFieldName, templateViewFileNameFieldName)); }