public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			Project p = parentNode.DataItem as Project;
			
			if (p is CProject)
				attributes |= NodeAttributes.Hidden;
		}
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			ProjectFile file = (ProjectFile) dataObject;

			attributes |= NodeAttributes.AllowRename;

			if (!file.Visible && !treeNavigator.Options ["ShowAllFiles"])
				attributes |= NodeAttributes.Hidden;
		}
		/// <summary>
		/// Gets the attributes of the given node. In this case, sets the hidden attribute if the node matches the Connected Services folder in the project root
		/// </summary>
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			var folder = (ProjectFolder)dataObject;

			if (parentNode != null && parentNode.DataItem is DotNetProject && folder.Path.FileName == ConnectedServices.ProjectStateFolderName)
			{
				attributes |= NodeAttributes.Hidden;
			}
		}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			Solution sol = (Solution) dataObject;
			foreach (DotNetProject p in sol.GetAllSolutionItems<DotNetProject> ()) {
				if (p.GetAddinData () != null)
					return;
			}
			attributes |= NodeAttributes.Hidden;
		}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			var fromPackagesFolderNode = parentNode.DataItem as ProjectReferencesFromPackagesFolderNode;
			if (fromPackagesFolderNode != null)
				return;

			var projectReference = (ProjectReference)dataObject;
			if (projectReference.IsReferenceFromPackage ()) {
				attributes |= NodeAttributes.Hidden;
			}
		}
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			ProjectFile file = (ProjectFile) dataObject;
			if (file.DependsOnFile != null) {
				attributes = NodeAttributes.None;
			} else {
				attributes |= NodeAttributes.AllowRename;
			}
			if (!file.Visible && !treeNavigator.Options ["ShowAllFiles"])
				attributes |= NodeAttributes.Hidden;
		}
        public override void GetNodeAttributes(ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
        {
            if (treeNavigator.Options ["ShowAllFiles"])
                return;

            ProjectFolder folder = dataObject as ProjectFolder;
            if (folder != null && folder.Project is DotNetProject && folder.Project.ExtendedProperties["QyotoDesignInfo"] != null) {
                QyotoDesignInfo info = QyotoDesignInfo.FromProject(folder.Project);
                if (info.QtGuiFolder == folder.Path)
                    attributes |= NodeAttributes.Hidden;
            }
        }
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			if (treeNavigator.Options ["ShowAllFiles"])
				return;

			ProjectFolder folder = dataObject as ProjectFolder;
			if (folder != null && folder.Project is DotNetProject) {
				GtkDesignInfo info = GtkDesignInfo.FromProject (folder.Project);
				if (info.GtkGuiFolder == folder.Path)
					attributes |= NodeAttributes.Hidden;
			}
		}
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			if (dataObject is GuiProjectFolder)
				return;
			
			ProjectFolder folder = dataObject as ProjectFolder;
			if (folder != null && folder.Project is DotNetProject) {
				GtkDesignInfo info = GtkDesignInfo.FromProject (folder.Project);
				if (info.SteticFolder == folder.Path)
					attributes |= NodeAttributes.Hidden;
			}
		}
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			if (treeNavigator.Options ["ShowAllFiles"])
				return;
			
			ProjectFile pf = (ProjectFile) dataObject;
			GtkDesignInfo info = GtkDesignInfo.FromProject (pf.Project);
			//Designer files in the designer folder like IconFactory.gtkx should be always visible
			if (info.HideGtkxFiles && 
			    pf.FilePath.Extension == ".gtkx" && 
			    !pf.FilePath.IsChildPathOf (info.SteticFolder))
				attributes |= NodeAttributes.Hidden;
		}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			var file = (ProjectFile) dataObject;

			if ((file.Flags & ProjectItemFlags.Hidden) != 0) {
				attributes |= NodeAttributes.Hidden;
				return;
			}

			attributes |= NodeAttributes.AllowRename;

			if (!file.Visible && !parentNode.Options ["ShowAllFiles"])
				attributes |= NodeAttributes.Hidden;
		}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			base.GetNodeAttributes (parentNode, dataObject, ref attributes);
			if (dataObject is ProjectFile) {
				string fname = ((ProjectFile)dataObject).Name;
				if (fname.EndsWith (".addin.xml", StringComparison.Ordinal) || fname.EndsWith (".addin", StringComparison.Ordinal)) {
					if (!(parentNode.DataItem is AddinData)) {
						DotNetProject dp = (DotNetProject) parentNode.GetParentDataItem (typeof(DotNetProject), true);
						if (dp != null && dp.GetAddinData () != null) {
							// Hide the manifest
							attributes |= NodeAttributes.Hidden;
						}
					}
				}
			}
		}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			if (dataObject is AddinProjectReference) {
				attributes |= NodeAttributes.Hidden;
				return;
			}
			ProjectReference pr = (ProjectReference) dataObject;
			DotNetProject parent = pr.OwnerProject as DotNetProject;
			if (AddinAuthoringService.IsProjectIncludedByAddin (parent, pr)) {
				attributes |= NodeAttributes.Hidden;
			}
			else if (parent.GetAddinData () != null && pr.ReferenceType == ReferenceType.Project) {
				DotNetProject tp = parent.ParentSolution.FindProjectByName (pr.Reference) as DotNetProject;
				if (tp != null && tp.GetAddinData () != null)
					attributes |= NodeAttributes.Hidden;
			}
		}
		/// <summary>Get the attributes for the current node.</summary>
		/// <param name="treeNavigator">ITreeNavigator containing the tree navigator.</param>
		/// <param name="dataObject">An object containing the value of the current node.</param>
		/// <param name="attributes">A NodeAttributes reference containing all the attribute for the current node.</param>
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			if (treeNavigator.Options ["ShowAllFiles"])
				return;
			
			ProjectFolder folder = dataObject as ProjectFolder;
			DotNetProject project = folder.Project as DotNetProject;
			if (project == null)
				return;
			
			foreach (var item in WebReferencesService.GetWebReferenceItems (project)) {
				if (folder.Path == item.BasePath.ParentDirectory.CanonicalPath) {
					attributes |= NodeAttributes.Hidden;
					break;
				}
			}
		}
			void UpdateNode (NodeBuilder[] chain, NodeAttributes ats, object dataObject)
			{
				string text;
				Gdk.Pixbuf icon;
				Gdk.Pixbuf closedIcon;
				GetNodeInfo (pad, this, chain, dataObject, out text, out icon, out closedIcon);
				SetNodeInfo (currentIter, ats, text, icon, closedIcon);
			}
			void UpdateNode (TreeNode n, NodeBuilder[] chain, NodeAttributes ats, object dataObject)
			{
				string text;
				Gdk.Pixbuf icon;
				Gdk.Pixbuf closedIcon;
				TreeBuilder.GetNodeInfo (tree, this, chain, dataObject, out text, out icon, out closedIcon);

				n.Text = text;
				n.Icon = icon;
				n.ClosedIcon = closedIcon;
				
				if (chain != null && chain.Length > 0)
					n.Name = ((TypeNodeBuilder)chain[0]).GetNodeName (this, n.DataItem);
				else
					n.Name = n.Text;
				
				n.Modified = true;
			}
Beispiel #17
0
 protected override void OnNodeReached(NodeAttributes node)
 {
     base.OnNodeReached(node);
     feedback.AddFunctionNameToTextMesh(currentTranslateType.CurrentFunctionName());
 }
Beispiel #18
0
			void UpdateNode (NodeBuilder[] chain, NodeAttributes ats, object dataObject)
			{
				var ni = GetNodeInfo (pad, this, chain, dataObject);
				SetNodeInfo (currentIter, ats, ni);
			}
Beispiel #19
0
        public override void GetNodeAttributes(ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
        {
            ProjectFile file = (ProjectFile)dataObject;

            if (file.DependsOnFile != null)
            {
                attributes = NodeAttributes.None;
            }
            else
            {
                attributes |= NodeAttributes.AllowRename;
            }
            if (!file.Visible && !treeNavigator.Options ["ShowAllFiles"])
            {
                attributes |= NodeAttributes.Hidden;
            }
        }
Beispiel #20
0
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
 }
Beispiel #21
0
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            var file = (ProjectFile)dataObject;

            if ((file.Flags & ProjectItemFlags.Hidden) != 0)
            {
                attributes |= NodeAttributes.Hidden;
                return;
            }

            attributes |= NodeAttributes.AllowRename;

            if (!file.Visible && !parentNode.Options ["ShowAllFiles"])
            {
                attributes |= NodeAttributes.Hidden;
            }
        }
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            Solution sol = (Solution)dataObject;

            foreach (DotNetProject p in sol.GetAllSolutionItems <DotNetProject> ())
            {
                if (p.GetAddinData() != null)
                {
                    return;
                }
            }
            attributes |= NodeAttributes.Hidden;
        }
 public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
 {
     base.GetNodeAttributes(parentNode, dataObject, ref attributes);
     if (dataObject is ProjectFile)
     {
         string fname = ((ProjectFile)dataObject).Name;
         if (fname.EndsWith(".addin.xml") || fname.EndsWith(".addin"))
         {
             if (!(parentNode.DataItem is AddinData))
             {
                 DotNetProject dp = (DotNetProject)parentNode.GetParentDataItem(typeof(DotNetProject), true);
                 if (dp != null && dp.GetAddinData() != null)
                 {
                     // Hide the manifest
                     attributes |= NodeAttributes.Hidden;
                 }
             }
         }
     }
 }
Beispiel #24
0
		// Helper methods
		
		internal static bool HasAttribute (ITreeNavigator treeNavigator, NodeAttributes attr, NodeBuilder[] chain, object dataObject)
		{
			NodeAttributes nodeAttr = NodeAttributes.None;
			NodePosition pos = treeNavigator.CurrentPosition;
			
			foreach (NodeBuilder nb in chain) {
				nb.GetNodeAttributes (treeNavigator, dataObject, ref nodeAttr);
				treeNavigator.MoveToPosition (pos);
			}
			
			return (nodeAttr & attr) != 0;
		}
		public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
		{
			attributes |= NodeAttributes.AllowRename;
		}
Beispiel #26
0
			void SetNodeInfo (Gtk.TreeIter it, NodeAttributes ats, NodeInfo nodeInfo)
			{
				store.SetValue (it, ExtensibleTreeView.TextColumn, nodeInfo.Label);
				store.SetValue (it, ExtensibleTreeView.OpenIconColumn, nodeInfo.Icon ?? CellRendererImage.NullImage);
				store.SetValue (it, ExtensibleTreeView.ClosedIconColumn, nodeInfo.ClosedIcon ?? CellRendererImage.NullImage);
				store.SetValue (it, ExtensibleTreeView.OverlayBottomLeftColumn, nodeInfo.OverlayBottomLeft ?? CellRendererImage.NullImage);
				store.SetValue (it, ExtensibleTreeView.OverlayBottomRightColumn, nodeInfo.OverlayBottomRight ?? CellRendererImage.NullImage);
				store.SetValue (it, ExtensibleTreeView.OverlayTopLeftColumn, nodeInfo.OverlayTopLeft ?? CellRendererImage.NullImage);
				store.SetValue (it, ExtensibleTreeView.OverlayTopRightColumn, nodeInfo.OverlayTopRight ?? CellRendererImage.NullImage);
				pad.Tree.QueueDraw ();
			}
		public override void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
			var folder = (Folder)dataObject;

			if(!folder.IsAssetsFolder())
				attributes |= NodeAttributes.AllowRename;
		}
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            var fromPackagesFolderNode = parentNode.DataItem as ProjectReferencesFromPackagesFolderNode;

            if (fromPackagesFolderNode != null)
            {
                return;
            }

            var projectReference = (ProjectReference)dataObject;

            if (projectReference.IsReferenceFromPackage())
            {
                attributes |= NodeAttributes.Hidden;
            }
        }
Beispiel #29
0
 public virtual void SetNodeAttributes(IAttributeDictionary attrs)
 {
     NodeAttributes.SetAttributes(attrs);
 }
Beispiel #30
0
 public virtual void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
 {
 }
 /// <summary>
 /// Updates the attributes for the node.
 /// </summary>
 private static void UpdateAttributes(ILocalNode node, NodeAttributes attributes)
 {
     // DisplayName
     if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.DisplayName) != 0)
     {
         node.DisplayName = attributes.DisplayName;
     
         if (node.DisplayName == null)
         {
             node.DisplayName = new LocalizedText(node.BrowseName.Name);
         }
     }
     else
     {
         node.DisplayName = new LocalizedText(node.BrowseName.Name);
     }
     
     // Description
     if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.Description) != 0)
     {
         node.Description = attributes.Description;
     }
              
     // WriteMask
     if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.WriteMask) != 0)
     {
         node.WriteMask = (AttributeWriteMask)attributes.WriteMask;
     }
     else
     {
         node.WriteMask = AttributeWriteMask.None;
     }
             
     // WriteMask    
     if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.UserWriteMask) != 0)
     {
         node.UserWriteMask = (AttributeWriteMask)attributes.UserWriteMask;
     }
     else
     {
         node.UserWriteMask = AttributeWriteMask.None;
     }
 }
Beispiel #32
0
 public override void GetNodeAttributes(ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
 {
     attributes |= NodeAttributes.AllowRename;
 }
            void UpdateNode(TreeNode n, NodeBuilder[] chain, NodeAttributes ats, object dataObject)
            {
                var ni = new NodeInfo ();
                n.NodeInfo = TreeBuilder.GetNodeInfo (ni, tree, this, chain, dataObject);

                if (chain != null && chain.Length > 0)
                    n.Name = ((TypeNodeBuilder)chain[0]).GetNodeName (this, n.DataItem);
                else
                    n.Name = n.NodeInfo.Label;

                n.Modified = true;
            }
            void UpdateNode(NodeBuilder[] chain, NodeAttributes ats, object dataObject)
            {
                Gdk.Pixbuf icon = null;
                Gdk.Pixbuf closedIcon = null;
                string text = string.Empty;
                Gtk.TreeIter citer = currentIter;

                foreach (NodeBuilder builder in chain) {
                    builder.BuildNode (this, dataObject, ref text, ref icon, ref closedIcon);
                    currentIter = citer;
                }

                if (closedIcon == null) closedIcon = icon;

                if (dataObject == pad.copyObject && pad.currentTransferOperation == DragOperation.Move) {
                    Gdk.Pixbuf gicon = pad.builderContext.GetComposedIcon (icon, "fade");
                    if (gicon == null) {
                        gicon = Runtime.Gui.Icons.MakeTransparent (icon, 0.5);
                        pad.builderContext.CacheComposedIcon (icon, "fade", gicon);
                    }
                    icon = gicon;
                    gicon = pad.builderContext.GetComposedIcon (closedIcon, "fade");
                    if (gicon == null) {
                        gicon = Runtime.Gui.Icons.MakeTransparent (closedIcon, 0.5);
                        pad.builderContext.CacheComposedIcon (closedIcon, "fade", gicon);
                    }
                    closedIcon = gicon;
                }

                SetNodeInfo (currentIter, ats, text, icon, closedIcon);
            }
Beispiel #35
0
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            if (parentNode.Options ["ShowAllFiles"])
            {
                return;
            }

            var folder = dataObject as ProjectFolder;

            if (folder == null)
            {
                return;
            }

            var project = folder.Project as DotNetProject;

            if (project == null)
            {
                return;
            }

            if (!project.HasFlavor <DotNetCoreProjectExtension> ())
            {
                return;
            }

            if (folder.Path.CanonicalPath == project.BaseIntermediateOutputPath.CanonicalPath)
            {
                attributes |= NodeAttributes.Hidden;
            }
        }
			void UpdateNode (NodeBuilder[] chain, NodeAttributes ats, object dataObject)
			{
				bool isNew = false;

				var ni = (NodeInfo)store.GetValue (currentIter, ExtensibleTreeView.NodeInfoColumn);
				if (ni == null || ni.IsShared) {
					ni = new NodeInfo ();
					isNew = true;
				}
				else
					ni.Reset ();

				GetNodeInfo (ni, pad, this, chain, dataObject);

				if (isNew)
					store.SetValue (currentIter, ExtensibleTreeView.NodeInfoColumn, ni);
				else
					store.EmitRowChanged (store.GetPath (currentIter), currentIter);
			}
			void BuildNode (Gtk.TreeIter it, NodeBuilder[] chain, NodeAttributes ats, object dataObject)
			{
				Gtk.TreeIter oldIter = currentIter;
				object oldItem = DataItem;

				InitIter (it, dataObject);
				
				// It is *critical* that we set this first. We will
				// sort after this call, so we must give as much info
				// to the sort function as possible.
				store.SetValue (it, ExtensibleTreeView.DataItemColumn, dataObject);
				store.SetValue (it, ExtensibleTreeView.BuilderChainColumn, chain);
				
				UpdateNode (chain, ats, dataObject);
				
				bool hasChildren = HasChildNodes (this, chain, dataObject);
				store.SetValue (currentIter, ExtensibleTreeView.FilledColumn, !hasChildren);
				
				if (hasChildren)
					store.AppendNode (currentIter);	// Dummy node

				InitIter (oldIter, oldItem);
			}
Beispiel #38
0
 public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
 {
     if (IsDotNetCoreProject(parentNode))
     {
         attributes |= NodeAttributes.Hidden;
     }
 }
			void SetNodeInfo (Gtk.TreeIter it, NodeAttributes ats, string text, Gdk.Pixbuf icon, Gdk.Pixbuf closedIcon)
			{
				store.SetValue (it, ExtensibleTreeView.TextColumn, text);
				if (icon != null) store.SetValue (it, ExtensibleTreeView.OpenIconColumn, icon);
				if (closedIcon != null) store.SetValue (it, ExtensibleTreeView.ClosedIconColumn, closedIcon);
				pad.Tree.QueueDraw ();
			}
 public void Init(ObjectNavigation navigation, NodeAttributes node)
 {
     dynamicRotation = navigation.MoveDirectionBasedRotation;
 }
Beispiel #41
0
		public virtual void GetNodeAttributes (ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
		{
		}
 public void Reset(NodeAttributes node, Transform from)
 {
     ResetCurrentTranslateTime();
 }
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            Project p = parentNode.DataItem as Project;

            if (p is ValaProject)
            {
                attributes |= NodeAttributes.Hidden;
            }
        }
        private void processContacts(Node node, NodeAttributes attributes,
                                     IEnumerable <FieldViewModel> customFields, int jobId,
                                     IEnumerable <DropdownValueViewModel> dropdownFields, string fileName)
        {
            #region Declarations
            StringBuilder                hash                = new StringBuilder();
            IList <Email>                emails              = new List <Email>();
            var                          guid                = Guid.NewGuid();
            RawContact                   contact             = new RawContact();
            IList <ImportCustomData>     contactCustomData   = new List <ImportCustomData>();
            IList <ImportPhoneData>      contactPhoneData    = new List <ImportPhoneData>();
            StringBuilder                customFieldData     = new StringBuilder();
            bool                         isDuplicateFromFile = false;
            LeadAdapterRecordStatus      status              = LeadAdapterRecordStatus.Undefined;
            SearchResult <Contact>       duplicateResult     = new SearchResult <Contact>();
            Dictionary <string, dynamic> oldNewValues        = new Dictionary <string, dynamic> {
            };
            #endregion

            #region BuilderNumber Validation
            string builderNumber     = attributes[_fieldMappings.GetOrDefault("BuilderNumber")].Value;
            bool   builderNumberPass = leadAdapterAndAccountMap.BuilderNumber.ToLower().Split(',').Contains(builderNumber.ToLower());
            #endregion

            #region Community Number Validation
            string communityNumber     = attributes[_fieldMappings.GetOrDefault("CommunityNumber")].Value;
            bool   communityNumberPass = true;
            #endregion

            #region ContactsProcessing
            string firstName    = attributes[_fieldMappings.GetOrDefault("FirstName")].Value;
            string lastName     = attributes[_fieldMappings.GetOrDefault("LastName")].Value;
            string primaryEmail = attributes[_fieldMappings.GetOrDefault("Email")].Value;
            string companyName  = string.Empty;

            #region HashPreparation
            Action <string> HashAppend = (n) =>
            {
                if (string.IsNullOrEmpty(n))
                {
                    hash.Append("-").Append(string.Empty);
                }
                else
                {
                    hash.Append("-").Append(n);
                }
            };

            if (!string.IsNullOrEmpty(primaryEmail))
            {
                Email _primaryemail = new Email()
                {
                    EmailId   = primaryEmail,
                    AccountID = leadAdapterAndAccountMap.AccountID,
                    IsPrimary = true
                };
                emails.Add(_primaryemail);
                hash.Append("-").Append(primaryEmail);
            }
            else
            {
                hash.Append("-").Append("*****@*****.**");
            }

            HashAppend(firstName);
            HashAppend(lastName);
            HashAppend(companyName);
            #endregion

            Person person = new Person()
            {
                FirstName   = firstName,
                LastName    = lastName,
                CompanyName = companyName,
                Emails      = emails,
                AccountID   = AccountID
            };


            if (builderNumberPass && communityNumberPass)
            {
                bool duplicatEemailCount = hashes.Any(h => !string.IsNullOrEmpty(primaryEmail) && h.Contains(primaryEmail));
                if (duplicatEemailCount ||
                    (string.IsNullOrEmpty(primaryEmail) && hashes.Where(h => h.Contains(hash.ToString())).Any()))
                {
                    isDuplicateFromFile = true;
                }
                else if (!duplicatEemailCount)
                {
                    isDuplicateFromFile = false;
                }
            }

            hashes.Add(hash.ToString());


            if (builderNumberPass && communityNumberPass)
            {
                SearchParameters parameters = new SearchParameters()
                {
                    AccountId = AccountID
                };
                IEnumerable <Contact> duplicateContacts = contactService.CheckIfDuplicate(new CheckContactDuplicateRequest()
                {
                    Person = person
                }).Contacts;
                duplicateResult = new SearchResult <Contact>()
                {
                    Results = duplicateContacts, TotalHits = duplicateContacts != null?duplicateContacts.Count() : 0
                };
            }

            if (!builderNumberPass)
            {
                status = LeadAdapterRecordStatus.BuilderNumberFailed;
            }
            else if (!communityNumberPass)
            {
                status = LeadAdapterRecordStatus.CommunityNumberFailed;
            }
            else if (isDuplicateFromFile)
            {
                status = LeadAdapterRecordStatus.DuplicateFromFile;
            }
            else if (duplicateResult.TotalHits > 0)
            {
                status = LeadAdapterRecordStatus.Updated;
                guid   = duplicateResult.Results.FirstOrDefault().ReferenceId;
            }
            else
            {
                status = LeadAdapterRecordStatus.Added;
            }


            Contact duplicatePerson = default(Person);

            if (status == LeadAdapterRecordStatus.Updated)
            {
                duplicatePerson = duplicateResult.Results.FirstOrDefault();
            }
            else
            {
                duplicatePerson = new Person();
            }

            Func <NodeAttribute, string, bool> checkIfStandardField = (name, field) =>
            {
                return(name.Name.ToLower() == _fieldMappings.GetOrDefault(field).NullSafeToLower());
            };

            try
            {
                foreach (var attribute in attributes)
                {
                    var name  = attribute.Name.ToLower();
                    var value = attribute.Value;

                    ImportCustomData customData = new ImportCustomData();
                    try
                    {
                        var elementValue = string.Empty;
                        if (checkIfStandardField(attribute, "FirstName"))
                        {
                            elementValue      = ((Person)duplicatePerson).FirstName == null ? string.Empty : ((Person)duplicatePerson).FirstName;
                            contact.FirstName = value;
                        }
                        else if (checkIfStandardField(attribute, "LastName"))
                        {
                            elementValue     = ((Person)duplicatePerson).LastName;
                            contact.LastName = value;
                        }
                        else if (checkIfStandardField(attribute, "Email"))
                        {
                            Email primaryemail = duplicatePerson.Emails.IsAny() ? duplicatePerson.Emails.Where(i => i.IsPrimary == true).FirstOrDefault() : null;
                            if (primaryemail != null)
                            {
                                elementValue = primaryemail.EmailId;
                            }
                            contact.PrimaryEmail = value;
                        }
                        else if (checkIfStandardField(attribute, "Company"))
                        {
                            // get company dynamic
                            elementValue        = duplicatePerson.CompanyName;
                            contact.CompanyName = value;
                        }
                        else if (checkIfStandardField(attribute, "PhoneNumber") || checkIfStandardField(attribute, "Phone"))
                        {
                            DropdownValueViewModel dropdownValue = dropdownFields.Where(i => i.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).FirstOrDefault();
                            var             mobilephone          = default(Phone);
                            ImportPhoneData phoneData            = new ImportPhoneData();
                            phoneData.ReferenceID = guid;
                            if (dropdownValue != null)
                            {
                                if (!string.IsNullOrEmpty(value))
                                {
                                    string phoneNumber = GetNonNumericData(value);
                                    if (IsValidPhoneNumberLength(phoneNumber))
                                    {
                                        contact.PhoneData     = dropdownValue.DropdownValueID.ToString() + "|" + phoneNumber;
                                        phoneData.PhoneType   = (int?)dropdownValue.DropdownValueID;
                                        phoneData.PhoneNumber = phoneNumber;
                                        contactPhoneData.Add(phoneData);
                                    }
                                }
                                mobilephone = duplicatePerson.Phones.IsAny() ? duplicatePerson.Phones.Where(i => i.PhoneType == dropdownValue.DropdownValueID).FirstOrDefault() : null;
                            }

                            if (mobilephone != null)
                            {
                                elementValue = mobilephone.Number;
                            }
                        }
                        else if (checkIfStandardField(attribute, "Country"))
                        {
                            var countryvalue = value.Replace(" ", string.Empty).ToLower();
                            if (countryvalue == "usa" || countryvalue == "us" || countryvalue == "unitedstates" || countryvalue == "unitedstatesofamerica")
                            {
                                contact.Country = "US";
                            }
                            else if (countryvalue == "ca" || countryvalue == "canada")
                            {
                                contact.Country = "CA";
                            }
                            else
                            {
                                contact.Country = value;
                            }
                        }
                        else if (checkIfStandardField(attribute, "StreetAddress"))
                        {
                            contact.AddressLine1 = value;
                        }
                        else if (checkIfStandardField(attribute, "City"))
                        {
                            contact.City = value;
                        }
                        else if (checkIfStandardField(attribute, "State"))
                        {
                            contact.State = value;
                        }
                        else if (checkIfStandardField(attribute, "PostalCode"))
                        {
                            contact.ZipCode = value;
                        }
                        else
                        {
                            var customField = customFields.Where(i => i.Title.Replace(" ", string.Empty).ToLower() == (name + "(" + leadAdapterType.ToString().ToLower() + ")")).FirstOrDefault();
                            if (customField != null)
                            {
                                var customfielddata = duplicatePerson.CustomFields == null ? null : duplicatePerson.CustomFields.Where(i => i.CustomFieldId == customField.FieldId).FirstOrDefault();
                                if (customfielddata != null)
                                {
                                    elementValue = customfielddata.Value;
                                }
                                customData.FieldID     = customField.FieldId;
                                customData.FieldTypeID = (int?)customField.FieldInputTypeId;
                                customData.ReferenceID = guid;

                                if (customField.FieldInputTypeId == FieldType.date || customField.FieldInputTypeId == FieldType.datetime || customField.FieldInputTypeId == FieldType.time)
                                {
                                    DateTime converteddate;
                                    if (DateTime.TryParse(value, out converteddate))
                                    {
                                        customFieldData.Append("~" + customField.FieldId + "##$##" + (byte)customField.FieldInputTypeId + "|" + converteddate.ToString("MM/dd/yyyy hh:mm tt"));
                                        customData.FieldValue = converteddate.ToString("MM/dd/yyyy hh:mm tt");
                                    }
                                }
                                else if (customField.FieldInputTypeId == FieldType.number)
                                {
                                    double number;
                                    if (double.TryParse(value, out number))
                                    {
                                        customFieldData.Append("~" + customField.FieldId + "##$##" + (byte)customField.FieldInputTypeId + "|" + number.ToString());
                                        customData.FieldValue = number.ToString();
                                    }
                                }
                                else if (customField.FieldInputTypeId == FieldType.url)
                                {
                                    if (IsValidURL(value.Trim()))
                                    {
                                        customFieldData.Append("~" + customField.FieldId + "##$##" + (byte)customField.FieldInputTypeId + "|" + value.Trim());
                                        customData.FieldValue = value.Trim();
                                    }
                                }
                                else
                                {
                                    customFieldData.Append("~" + customField.FieldId + "##$##" + (byte)customField.FieldInputTypeId + "|" + value.Trim());
                                    customData.FieldValue = value.Trim();
                                }
                                contactCustomData.Add(customData);
                            }
                        }
                        if (!oldNewValues.ContainsKey(attribute.Name))
                        {
                            oldNewValues.Add(attribute.Name, new { OldValue = string.IsNullOrEmpty(elementValue) ? string.Empty : elementValue, NewValue = value });
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Current.Error("An exception occured in Genereating old new values element in Trulia : " + attribute.Name, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Current.Error("An exception occured in Genereating old new values element in Trulia : ", ex);
            }
            #endregion

            if (customFieldData.Length > 0)
            {
                customFieldData.Remove(0, 1);
            }
            contact.CustomFieldsData = customFieldData.ToString();

            contact.ReferenceId               = guid;
            contact.AccountID                 = AccountID;
            contact.IsBuilderNumberPass       = builderNumberPass;
            contact.IsCommunityNumberPass     = communityNumberPass;
            contact.LeadAdapterRecordStatusId = (byte)status;
            contact.JobID           = jobId;
            contact.ContactStatusID = 1;
            contact.ContactTypeID   = 1;
            JavaScriptSerializer js = new JavaScriptSerializer();
            contact.LeadAdapterSubmittedData = js.Serialize(oldNewValues);
            contact.LeadAdapterRowData       = node.Current != null?node.Current.ToString() : string.Empty;

            personCustomFieldData.AddRange(contactCustomData);
            personPhoneData.AddRange(contactPhoneData);

            contact.ValidEmail = ValidateEmail(contact);

            RawContact duplicate_data = null;
            if (!string.IsNullOrEmpty(contact.PrimaryEmail))
            {
                duplicate_data = persons.Where(p => string.Compare(p.PrimaryEmail, contact.PrimaryEmail, true) == 0).FirstOrDefault();
            }
            else
            {
                duplicate_data = persons.Where(p => string.Compare(p.FirstName, contact.FirstName, true) == 0 &&
                                               string.Compare(p.LastName, contact.LastName, true) == 0).FirstOrDefault();
            }

            if (duplicate_data != null)
            {
                contact.IsDuplicate = true;
                //RawContact updatedperson = MergeDuplicateData(duplicate_data, contact, guid);
                //duplicate_data = updatedperson;
            }

            persons.Add(contact);
        }