Beispiel #1
0
        public ContentResult GetRowImages(string rowViewName, string key, string imageViewName)
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<xml></xml>";

            Durados.Web.Mvc.View imageView = (Durados.Web.Mvc.View)Map.Database.Views[imageViewName];

            Dictionary <string, object> values = new Dictionary <string, object>();
            Field field = imageView.Fields.Values.Where(f => f.FieldType.Equals(FieldType.Parent) && ((ParentField)f).ParentView.Name.Equals(rowViewName)).FirstOrDefault();

            values.Add(field.Name, key);

            Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>();

            if (imageView.DataTable.Columns.Contains(imageView.OrdinalColumnName))
            {
                sortColumns.Add(imageView.OrdinalColumnName, SortDirection.Asc);
            }

            int      rowCount = 0;
            DataView dataView = imageView.FillPage(1, 1000, values, false, sortColumns, out rowCount, null, null);


            foreach (DataRow row in dataView.Table.Rows)
            {
                XmlElement   element = xml.CreateElement("File");
                XmlAttribute name    = xml.CreateAttribute("name");
                name.Value = row[imageView.ImageSrcColumnName].ToString();
                element.Attributes.Append(name);
                xml.DocumentElement.AppendChild(element);
            }
            return(this.Content(xml.InnerXml, "text/xml"));
        }
Beispiel #2
0
        public virtual ContentResult GetRows(string rowsViewName)
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<xml></xml>";

            Durados.Web.Mvc.View view = (Durados.Web.Mvc.View)Map.Database.Views[rowsViewName];

            Dictionary <string, object> values = new Dictionary <string, object>();

            Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>();

            sortColumns.Add(view.DisplayColumn, SortDirection.Asc);
            int      rowCount = 0;
            DataView dataView = view.FillPage(1, 1000, values, false, sortColumns, out rowCount, null, null);


            foreach (DataRow row in dataView.Table.Rows)
            {
                XmlElement   element = xml.CreateElement("Row");
                XmlAttribute key     = xml.CreateAttribute("key");
                key.Value = view.GetPkValue(row);
                element.Attributes.Append(key);
                XmlAttribute name = xml.CreateAttribute("name");
                name.Value = GetDisplayName(view, row);
                element.Attributes.Append(name);

                AddAdditionals(view, xml, element, row);
                xml.DocumentElement.AppendChild(element);
            }
            return(this.Content(xml.InnerXml, "text/xml"));
        }
Beispiel #3
0
        protected virtual Dictionary <string, bool> GetEmails(string distributionListsName, Database database)
        {
            Durados.Web.Mvc.View distributionView = (Durados.Web.Mvc.View)database.Views[GetDistributionViewName()];

            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add("Name", distributionListsName);

            int      rowCount = 0;
            DataView dataView = distributionView.FillPage(1, 1000, values, false, null, out rowCount, null, null);


            Dictionary <string, bool> emails = new Dictionary <string, bool>();

            foreach (System.Data.DataRowView row in dataView)
            {
                string email          = row.Row["Email"].ToString();
                bool   pointOfContact = (bool)row.Row["PointOfContact"];

                if (emails.ContainsKey(email))
                {
                    if (!emails[email] && pointOfContact)
                    {
                        emails[email] = true;
                    }
                }
                else
                {
                    emails.Add(email, pointOfContact);
                }
            }


            return(emails);
        }
Beispiel #4
0
        private DataView GetNodesTable(string parentKey)
        {
            if (!view.Fields.ContainsKey(view.TreeRelatedFieldName))
            {
                throw new DuradosException("The View '" + view.DisplayName + "' doeas not contain the Tree Related Field Name '" + view.TreeRelatedFieldName + "'.");
            }

            if (view.Database.IsConfig)
            {
                if (string.IsNullOrEmpty(parentKey))
                {
                    parentKey = "[null]";
                }

                Dictionary <string, object> filter = new Dictionary <string, object>();
                filter.Add(view.TreeRelatedFieldName, parentKey);

                int      rowCount = 0;
                DataView dataView = view.FillPage(1, 1000000, filter, false, null, out rowCount, null, null);

                return(dataView);
            }
            else
            {
                return(new DataView(GetNodesTableFromDb(parentKey)));
            }
        }
Beispiel #5
0
        public virtual void MatchFields(string viewName)
        {
            Durados.Web.Mvc.View view      = GetView(viewName);
            Durados.Web.Mvc.View fieldView = GetView(GearViews.durados_Field.ToString());

            Dictionary <string, object> values = new Dictionary <string, object>();

            int      rowCount = 0;
            DataView dataView = fieldView.FillPage(1, 1000, values, null, SortDirection.Asc, out rowCount, null, null);

            foreach (DataRow row in dataView.Table.Rows)
            {
                string displayName = row[durados_Field.DisplayName.ToString()].ToString();
                string name        = row[durados_Field.Name.ToString()].ToString();
                if (view.Fields.ContainsKey(name))
                {
                    view.Fields[name].DisplayName = displayName;
                }
            }

            Durados.Web.Mvc.Map.SaveConfigForThwFirstTimeInCaseOfChangeInStructure();
        }
Beispiel #6
0
        public JsonResult getview(int bookmarkid, int?pageSize, int?pageNumber)
        {
            Guid guid = Guid.NewGuid();

            Database.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), "getview(" + guid.ToString() + ")", "Start", null, 3, "Parameters:" + bookmarkid.ToString(), DateTime.Now);
            if (!IsValidatUser())
            {
                return(Json(new TableForJson {
                    ErrorCode = 101, ErrorDescription = "User is not recognize"
                }));
            }

            int maxPageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ApiGetViewMaxPageSize"] ?? "10000");

            if (!pageSize.HasValue)
            {
                pageSize = maxPageSize;
            }

            if (pageSize.HasValue && pageSize.Value > maxPageSize)
            {
                return(Json(new TableForJson {
                    ErrorCode = 121, ErrorDescription = "Page size exceeded the allowed value of 10000"
                }));
            }
            if (!pageNumber.HasValue)
            {
                pageNumber = 1;
            }

            List <Dictionary <object, object> > rows;
            int rowCount;

            try
            {
                Durados.Bookmark bookmark = BookmarksHelper.GetBookmark(bookmarkid);
                if (bookmark == null)
                {
                    return(Json(new TableForJson {
                        ErrorCode = 102, ErrorDescription = "Bookmark was not found"
                    }));
                }
                ;

                Durados.Web.Mvc.View view = GetView(bookmark.ViewName, "getview");
                if (view == null)
                {
                    return(Json(new TableForJson {
                        ErrorCode = 103, ErrorDescription = "View " + bookmark.ViewName + "was not found"
                    }));
                }
                if (view.Database.IsConfig)
                {
                    return(Json(new TableForJson {
                        ErrorCode = 104, ErrorDescription = "Bookmark view is a config view! notofication services for these views is not implemeneted."
                    }));
                }



                DataAccess.Filter filter = MailingServiceHelper.GetBookmarkFilter(view, bookmark, new SqlAccess());
                Dictionary <string, SortDirection> sortColumns = GetSortColumns(bookmark.SortColumn, bookmark.SortDirection);
                DataView dataview;
                try
                {
                    dataview = view.FillPage(pageNumber.Value, pageSize.Value, filter, null, null, sortColumns, out rowCount, null, null);//GetDataViewByBookmark(bookmarkid,pageNumber,pageSize,out rowCount);
                }
                catch (Exception ex)
                {
                    throw new DuradosException("Faild to fill data view from database", ex);
                }
                //DataTable dt;
                //try
                //{
                //    dt = CreateResponseDataTable(view, dataview);
                //}
                //catch (Exception ex)
                //{
                //    throw new DuradosException("Faild to create response ", ex);
                //}

                rows = dataview.GetTableForJson(view, rowCount, pageNumber.Value);

                TableForJson tableJson = new TableForJson();
                tableJson.totalRowCount = rowCount;
                tableJson.results       = rows;
                tableJson.rowsInPage    = rows.Count;
                tableJson.pageNumber    = pageNumber.Value;
                Database.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), "getview(" + guid.ToString() + ")", "end", null, 3, null, DateTime.Now);
                return(Json(tableJson));
            }
            catch (Exception ex)
            {
                Database.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), "getview(" + guid.ToString() + ")", ex, 3, "end", DateTime.Now);
                return(Json(new TableForJson {
                    ErrorCode = 105, ErrorDescription = (ex.InnerException == null ? ex.Message : string.Format("Exeception Message {0};Inner Exception Message:{1}", ex.Message, ex.InnerException.Message))
                }));
            }
        }