コード例 #1
0
        private static void removeUnnecessaryLinksAttributes(savedqueryLayoutxmlGrid viewFeo, ViewExcelSheetsInfo excelData)
        {
            FetchEntityType   currentEt = excelData.fetchObj.Items.Where(x => x is FetchEntityType).Select(x => (FetchEntityType)x).FirstOrDefault();
            ViewsRelationsObj obj       = excelData.relationsList.Where(x => x.relationAlias == null).FirstOrDefault();

            if (currentEt != null && obj != null)
            {
                List <object> array = currentEt.Items.ToList();
                for (int i = array.Count - 1; i > -1; i--)
                {
                    object currentItem = array[i];
                    if (currentItem is FetchLinkEntityType)
                    {
                        FetchLinkEntityType link = currentItem as FetchLinkEntityType;
                        removeUnnecessaryAttributesInner(link, viewFeo);
                        if (link == null || link.visible == false)
                        {
                            if (link == null || link.Items.Count() == 0)
                            {
                                array.RemoveAt(i);
                            }
                        }
                    }
                    else if (currentItem is FetchAttributeType)
                    {
                        FetchAttributeType attr = currentItem as FetchAttributeType;
                        if (!(viewFeo.row.cell.Where(x => x.name == attr.name).Count() > 0) && attr.name != obj.entityMetadata.PrimaryIdAttribute)
                        {
                            array.RemoveAt(i);
                        }
                    }
                }
                currentEt.Items = array.ToArray();
            }
        }
コード例 #2
0
        public static string MapObjToViewXml(savedqueryLayoutxmlGrid viewXml)
        {
            string viewstring = null;

            try
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration = true;
                using (MemoryStream ms = new MemoryStream())
                {
                    XmlSerializerNamespaces names = new XmlSerializerNamespaces();
                    names.Add("", "");
                    XmlWriter stringWriter = null;
                    using (stringWriter = XmlWriter.Create(ms, settings))
                    {
                        XmlSerializer serializer1 = new XmlSerializer(typeof(savedqueryLayoutxmlGrid));
                        serializer1.Serialize(stringWriter, viewXml, names);
                        ms.Flush();
                        ms.Seek(0, SeekOrigin.Begin);
                        using (StreamReader sr = new StreamReader(ms))
                        {
                            viewstring = sr.ReadToEnd();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //------To Handle
            }
            return(viewstring);
        }
コード例 #3
0
 public ViewExcelSheetsInfo(Guid viewId, string layoutXml, string fetchxml, savedqueryLayoutxmlGrid viewObj, FetchType fetchObj, Guid enitityid, string entity)
     : base(ExcelSheetType.view, viewId.ToString())
 {
     this.fetchxml  = fetchxml;
     this.viewId    = viewId;
     this.layoutXml = layoutXml;
     this.viewObj   = viewObj;
     this.fetchObj  = fetchObj;
     this.isNew     = false;
     this.enitityid = enitityid;
     this.entity    = entity;
 }
コード例 #4
0
        public static savedqueryLayoutxmlGrid MapViewXmlToObj(string viewXml)
        {
            savedqueryLayoutxmlGrid viewType = null;

            try
            {
                StringReader stringReader = null;
                using (stringReader = new StringReader(viewXml))
                {
                    XmlSerializer serializer1 = new XmlSerializer(typeof(savedqueryLayoutxmlGrid));
                    viewType = (savedqueryLayoutxmlGrid)serializer1.Deserialize(stringReader);
                }
            }
            catch (Exception e)
            {
                //------To Handle
            }
            return(viewType);
        }
コード例 #5
0
        public void CreatenNewViewSheet(Guid viewId, Guid entity)
        {
            Entity         view                  = CRMOpHelper.GetView(viewId);
            EntityMetadata etMetadata            = CRMOpHelper.RetriveEntityAtrribute(entity);
            IEnumerable <AttributeMetadata> attr = etMetadata.Attributes.Where(x => x.AttributeType != null && x.AttributeType == AttributeTypeCode.Lookup);

            if (view != null && view.Contains("name") && view.Contains("layoutxml") && view.Contains("returnedtypecode") && view.Contains("fetchxml"))
            {
                GlobalApplicationData data      = GlobalApplicationData.Instance;
                string sheetName                = string.Format("{0} - {1}", view["name"].ToString(), view["returnedtypecode"].ToString());
                savedqueryLayoutxmlGrid viewObj = FormXmlMapper.MapViewXmlToObj(view.Attributes["layoutxml"].ToString());
                FetchType fatchObj              = FormXmlMapper.MapFetchXmlToObj(view.Attributes["fetchxml"].ToString());
                CreatenNewExcelSheet(sheetName, new ViewExcelSheetsInfo(viewId, view.Attributes["layoutxml"].ToString(), view.Attributes["fetchxml"].ToString(), viewObj, fatchObj, entity, etMetadata.LogicalName));
                ViewExcelSheetsInfo currentSheet = ((ViewExcelSheetsInfo)data.eSheetsInfomation.getCurrentSheet());
                currentSheet.language      = GlobalApplicationData.Instance.currentLanguage;
                currentSheet.relationsList = ViewXml.GenerateViewRelatedObj(currentSheet);
                ExcelOperations.RefreshViewSheet(data.eSheetsInfomation.getCurrentSheet(), attr);
            }
        }
コード例 #6
0
        private static string getViewXmlString(List <ViewFeo> viewFeoList, savedqueryLayoutxmlGrid viewObj)
        {
            List <savedqueryLayoutxmlGridRowCell> newcellList = new List <savedqueryLayoutxmlGridRowCell>();

            if (viewObj.row != null && viewObj.row.cell != null)
            {
                List <savedqueryLayoutxmlGridRowCell> oldcellList = viewObj.row.cell.ToList();
                foreach (ViewFeo viewFeo in viewFeoList)
                {
                    if (viewFeo.AttributeObj != null)
                    {
                        string attributeNameAlias = string.IsNullOrEmpty(viewFeo.AttributeObj.relationAlias) ? viewFeo.AttributeName : string.Concat(viewFeo.AttributeObj.relationAlias, ".", viewFeo.AttributeName);
                        addCellToView(newcellList, oldcellList, attributeNameAlias, viewFeo.AttributeWidth);
                    }
                    else
                    {
                        throw new Exception("Relation Not Found");
                    }
                }
                viewObj.row.cell = newcellList.ToArray();
            }
            return(FormXmlMapper.MapObjToViewXml(viewObj));
        }
コード例 #7
0
 private static void removeUnnecessaryAttributesInner(FetchLinkEntityType link, savedqueryLayoutxmlGrid viewFeo)
 {
     if (link.Items != null)
     {
         List <object> array = link.Items.ToList();
         for (int i = array.Count - 1; i > -1; i--)
         {
             object currentItem = array[i];
             if (currentItem is FetchAttributeType)
             {
                 FetchAttributeType attr  = currentItem as FetchAttributeType;
                 string             alias = string.Format("{0}.{1}", link.alias, attr.name);
                 if (!(viewFeo.row.cell.Where(x => x.name == attr.name).Count() > 0))
                 {
                     array.RemoveAt(i);
                 }
             }
         }
         link.Items = array.ToArray();
     }
 }