Пример #1
0
		//private ContactManager contact_manager;
		
		public ContactWindow (ContactManager contact_manager, Uri uri)
		{
			this.uri = uri;
			//this.contact_manager = contact_manager;
			
			ShowWindow ();
		}
 public virtual bool Save(ContactManager.User user)
 {
     ContactManager.User user1 = user;
     if ((user1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     return user1.Save();
 }
 public virtual bool Save(ContactManager.ContactSource contactSource)
 {
     ContactManager.ContactSource contactSource1 = contactSource;
     if ((contactSource1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     return contactSource1.Save();
 }
 public virtual bool Save(ContactManager.Address address)
 {
     ContactManager.Address address1 = address;
     if ((address1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     return address1.Save();
 }
 public virtual bool Delete(ContactManager.Contact contact)
 {
     ContactManager.Contact contact1 = contact;
     if ((contact1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     return contact1.Delete();
 }
 public virtual string Validate(ContactManager.ContactSource contactSource, string culture)
 {
     System.Globalization.CultureInfo cultureInfo = ConvertUtilities.ToCultureInfo(culture);
     ContactManager.ContactSource contactSource1 = contactSource;
     if ((contactSource1 == null))
     {
         return default(string);
     }
     return contactSource1.Validate(cultureInfo);
 }
 public virtual string Validate(ContactManager.User user, string culture)
 {
     System.Globalization.CultureInfo cultureInfo = ConvertUtilities.ToCultureInfo(culture);
     ContactManager.User user1 = user;
     if ((user1 == null))
     {
         return default(string);
     }
     return user1.Validate(cultureInfo);
 }
 public virtual string Validate(ContactManager.Address address, string culture)
 {
     System.Globalization.CultureInfo cultureInfo = ConvertUtilities.ToCultureInfo(culture);
     ContactManager.Address address1 = address;
     if ((address1 == null))
     {
         return default(string);
     }
     return address1.Validate(cultureInfo);
 }
 public virtual bool SaveByRef(ref ContactManager.Address address)
 {
     ContactManager.Address address1 = address;
     if ((address1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     bool ret = address1.Save();
     address = address1;
     return ret;
 }
Пример #10
0
 public virtual bool SaveByRef(ref ContactManager.User user)
 {
     ContactManager.User user1 = user;
     if ((user1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     bool ret = user1.Save();
     user = user1;
     return ret;
 }
 public virtual bool SaveByRef(ref ContactManager.ContactSource contactSource)
 {
     ContactManager.ContactSource contactSource1 = contactSource;
     if ((contactSource1 == null))
     {
         return CodeFluentPersistence.DefaultBooleanValue;
     }
     bool ret = contactSource1.Save();
     contactSource = contactSource1;
     return ret;
 }
Пример #12
0
    public static bool DeleteContact(Int32 contactId)
    {
        using (var contactManager = new ContactManager(null))
        {   
            try
            {
                contactManager.DeleteContact(contactId);
                return true;
            }
            catch 
            {
                return false;
            }
          
        }

    
    }
Пример #13
0
        public ContactService(ContactManager contactManager)
        {
            if (contactManager == null)
                throw new ArgumentNullException("contactManager");

            this._contactManager = contactManager;

            foreach (var group in this._contactManager.Groups)
            {
                var contactCollection = group as ContactCollection;
                if (contactCollection == null)
                    throw new ArgumentOutOfRangeException();

                foreach (var contact in contactCollection)
                {
                    contact.ContactInformationChanged += contact_ContactInformationChanged;
                }
            }
        }
Пример #14
0
    static void Main(string[] args)
    {
        MyImApp imApp = new MyImApp();

        if (imApp == null)
        {
            return;
        }

        UCOfficeIntegration officeIntegration = (UCOfficeIntegration)imApp;

        if (officeIntegration == null)
        {
            return;
        }

        officeIntegration.OnShuttingDown += officeIntegration_OnShuttingDown;

        string    officeVersion     = "15.0.0.0";
        string    authInfo          = officeIntegration.GetAuthenticationInfo(officeVersion);
        OIFeature supportedFeatures = officeIntegration.GetSupportedFeatures(officeVersion);  //skype reports: -122

        LyncClient lyncClient = (LyncClient)officeIntegration.GetInterface(officeVersion, OIInterface.oiInterfaceILyncClient);

        if (lyncClient == null)
        {
            return;
        }

        string uri = lyncClient.Uri;

        IAutomation automation = (IAutomation)officeIntegration.GetInterface(officeVersion, OIInterface.oiInterfaceIAutomation);

        //LyncClientCapabilityTypes capabilities = lyncClient.Capabilities; //skype: Not implemented
        lyncClient.OnStateChanged += lyncClient_OnStateChanged;

        ContactManager contactManager = lyncClient.ContactManager;

        if (contactManager == null)
        {
            return;
        }


        AsynchronousOperation async = contactManager.Lookup("*****@*****.**", myContactsAndGroupsCallback, Type.Missing);

        Contact contact = contactManager.GetContactByUri("*****@*****.**");

        if (contact != null)
        {
            dynamic result = contact.GetContactInformation(ContactInformationType.ucPresenceInstantMessageAddresses);

            ContactSettingDictionary settings = contact.Settings;

            ContactSetting[] keys = settings.Keys;

            if (keys != null)
            {
                foreach (ContactSetting key in keys)
                {
                    object value = null;
                    settings.TryGetValue(key, out value);
                }
            }
        }

        Console.CancelKeyPress += Console_CancelKeyPress;

        Console.WriteLine("Press Ctrl-C for exit");

        do
        {
            System.Threading.Thread.Sleep(1000);
        } while (!cancelPressed);
    }
        public Contact AddContact(Contact contact)
        {
            Contact result = new ContactManager().AddContact(contact);

            return result;
        }
        public static void Initialize()
        {
            try
            {
                _client = LyncClient.GetClient();
                LyncContactManager = _client.ContactManager;
            }
            catch (ClientNotFoundException clne)
            {
                throw new Exception("Ensure Lync client is installed and is configured to run in Full UI suppression mode", clne);
            }

            if (!_client.InSuppressedMode)
                throw new ApplicationException("Ensure Lync client is configured to run in Full UI suppression mode");

            if (_client.State != ClientState.Uninitialized)
                throw new ApplicationException(string.Format("Client is in state '{0}', expected '{1}'", _client.State, ClientState.Uninitialized));

            _client.EndInitialize(_client.BeginInitialize(null, null));

            _client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
            _client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
        }
Пример #17
0
 public ContactFacetsProvider()
 {
     _contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
 }
Пример #18
0
 public ContactController()
 {
     _contactManager = new ContactManager();
 }
 public virtual void SaveAll(ContactManager.AddressCollection addressCollection)
 {
     ContactManager.AddressCollection addressCollection1 = addressCollection;
     addressCollection1.SaveAll();
 }
        public void Subscriber(IContactDetailService clientObject)
        {
            ContactManager subscribe = ContactManager.GetInstance();

            subscribe.Subscribe(clientObject);
        }
Пример #21
0
 /// <summary>
 /// Constructor with search callback
 /// </summary>
 /// <param name="contacts"></param>
 /// <param name="searchCallback"></param>
 public ContactHelper(ContactManager contacts, OnFindContacts searchCallback)
     : this(contacts)
 {
     this._doSomethingWithContact = searchCallback;
 }
Пример #22
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="contacts"></param>
 private ContactHelper(ContactManager contacts)
 {
     this._contacts = contacts;
 }
Пример #23
0
        private static async Task <PermissionStatus> CheckContactsAsync()
        {
            var accessStatus = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);

            return(accessStatus == null ? PermissionStatus.Denied : PermissionStatus.Granted);
        }
        public async Task RefreshContacts()
        {
            CancellationTokenSource cancelSource = new CancellationTokenSource();

            RefreshingContacts = true;
            Contacts.Clear();
            signalContacts.Clear();
            ContactStore contactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly);

            List <PhoneContact> intermediateContacts = new List <PhoneContact>();

            if (contactStore != null)
            {
                HashSet <string> seenNumbers = new HashSet <string>();
                var contacts = await contactStore.FindContactsAsync();

                ContactAnnotationStore contactAnnotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

                ContactAnnotationList contactAnnotationList;
                var contactAnnotationLists = await contactAnnotationStore.FindAnnotationListsAsync();

                if (contactAnnotationLists.Count == 0)
                {
                    contactAnnotationList = await contactAnnotationStore.CreateAnnotationListAsync();
                }
                else
                {
                    contactAnnotationList = contactAnnotationLists[0];
                }

                foreach (var contact in contacts)
                {
                    var phones = contact.Phones;
                    foreach (var phone in contact.Phones)
                    {
                        if (phone.Kind == ContactPhoneKind.Mobile)
                        {
                            string formattedNumber = null;
                            try
                            {
                                formattedNumber = ParsePhoneNumber(phone.Number);
                            }
                            catch (NumberParseException)
                            {
                                Logger.LogDebug("RefreshContacts() could not parse number");
                                continue;
                            }
                            if (!seenNumbers.Contains(formattedNumber))
                            {
                                seenNumbers.Add(formattedNumber);
                                PhoneContact phoneContact = new PhoneContact
                                {
                                    Id          = contact.Id,
                                    Name        = contact.FullName,
                                    PhoneNumber = formattedNumber,
                                    OnSignal    = false
                                };
                                if (contact.SourceDisplayPicture != null)
                                {
                                    using (var stream = await contact.SourceDisplayPicture.OpenReadAsync())
                                    {
                                        BitmapImage bitmapImage = new BitmapImage();
                                        await bitmapImage.SetSourceAsync(stream);

                                        phoneContact.Photo = bitmapImage;
                                    }
                                }
                                intermediateContacts.Add(phoneContact);
                            }
                        }
                    }
                }

                // check if we've annotated a contact as a Signal contact already, if we have we don't need to ask Signal about them
                for (int i = 0; i < intermediateContacts.Count; i++)
                {
                    var annotatedContact = await contactAnnotationList.FindAnnotationsByRemoteIdAsync(intermediateContacts[i].PhoneNumber);

                    if (annotatedContact.Count > 0)
                    {
                        intermediateContacts[i].OnSignal = true;
                        signalContacts.Add(intermediateContacts[i]);
                        intermediateContacts.RemoveAt(i);
                        i--;
                    }
                }

                List <string> intermediateContactPhoneNumbers = intermediateContacts.Select(c => c.PhoneNumber).ToList();
                var           registeredUsers = await accountManager.GetRegisteredUsersAsync(intermediateContactPhoneNumbers, LibUtils.SignalSettings.ContactDiscoveryServiceEnclaveId, cancelSource.Token);

                foreach (var contact in intermediateContacts)
                {
                    var foundContact = registeredUsers.FirstOrDefault(c => c.Key == contact.PhoneNumber);
                    if (!string.IsNullOrEmpty(foundContact.Key))
                    {
                        contact.OnSignal   = true;
                        contact.SignalGuid = foundContact.Value;
                        ContactAnnotation contactAnnotation = new ContactAnnotation
                        {
                            ContactId           = contact.Id,
                            RemoteId            = contact.PhoneNumber,
                            SupportedOperations = ContactAnnotationOperations.Message | ContactAnnotationOperations.ContactProfile
                        };
                        contactAnnotation.ProviderProperties.Add(nameof(contact.SignalGuid), foundContact.Value);
                        await contactAnnotationList.TrySaveAnnotationAsync(contactAnnotation);

                        signalContacts.Add(contact);
                    }
                }
                Contacts.AddRange(signalContacts);
            }
            else
            {
                ContactsVisible = false;
            }
            RefreshingContacts = false;
        }
Пример #25
0
 private async Task <ContactStore> Store()
 {
     return(await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite));
 }
Пример #26
0
        /// <summary>
        /// Update the contact manifold and touching status.
        /// Note: do not assume the fixture AABBs are overlapping or are valid.
        /// </summary>
        /// <param name="contactManager">The contact manager.</param>
        internal void Update(ContactManager contactManager)
        {
            Manifold oldManifold = Manifold;

            // Re-enable this contact.
            Flags |= ContactFlags.Enabled;

            bool touching;
            bool wasTouching = (Flags & ContactFlags.Touching) == ContactFlags.Touching;

            bool sensor = FixtureA.IsSensor || FixtureB.IsSensor;

            Body bodyA = FixtureA.Body;
            Body bodyB = FixtureB.Body;

            // Is this contact a sensor?
            if (sensor)
            {
                Shape shapeA = FixtureA.Shape;
                Shape shapeB = FixtureB.Shape;
                //touching = AABB.TestOverlap(shapeA, ChildIndexA, shapeB, ChildIndexB, ref bodyA.Xf, ref bodyB.Xf);

                //HACK: Super hack sensor overlap, triggers if AABBs overlap
                AABB AABBA, AABBB;
                shapeA.ComputeAABB(out AABBA, ref bodyA.Xf, 0);
                shapeB.ComputeAABB(out AABBB, ref bodyB.Xf, 0);
                touching = AABB.TestOverlap(ref AABBA, ref AABBB);

                // Sensors don't generate manifolds.
                Manifold.PointCount = 0;
            }
            else
            {
                Evaluate(ref Manifold, ref bodyA.Xf, ref bodyB.Xf);
                touching = Manifold.PointCount > 0;

                // Match old contact ids to new contact ids and copy the
                // stored impulses to warm start the solver.
                for (int i = 0; i < Manifold.PointCount; ++i)
                {
                    ManifoldPoint mp2 = Manifold.Points[i];
                    mp2.NormalImpulse = 0.0f;
                    mp2.TangentImpulse = 0.0f;
                    ContactID id2 = mp2.Id;

                    for (int j = 0; j < oldManifold.PointCount; ++j)
                    {
                        ManifoldPoint mp1 = oldManifold.Points[j];

                        if (mp1.Id.Key == id2.Key)
                        {
                            mp2.NormalImpulse = mp1.NormalImpulse;
                            mp2.TangentImpulse = mp1.TangentImpulse;
                            break;
                        }
                    }

                    Manifold.Points[i] = mp2;
                }

                if (touching != wasTouching)
                {
                    bodyA.Awake = true;
                    bodyB.Awake = true;
                }
            }

            if (touching)
            {
                Flags |= ContactFlags.Touching;
            }
            else
            {
                Flags &= ~ContactFlags.Touching;
            }

            if (wasTouching == false)
            {
                if (touching)
                {
#if true
                    bool enabledA, enabledB;

                    // Report the collision to both participants. Track which ones returned true so we can
                    // later call OnSeparation if the contact is disabled for a different reason.
                    if (FixtureA.OnCollision != null)
                        enabledA = FixtureA.OnCollision(FixtureA, FixtureB, this);
                    else
                        enabledA = true;

                    // Reverse the order of the reported fixtures. The first fixture is always the one that the
                    // user subscribed to.
                    if (FixtureB.OnCollision != null)
                        enabledB = FixtureB.OnCollision(FixtureB, FixtureA, this);
                    else
                        enabledB = true;

                    Enabled = enabledA && enabledB;

                    // BeginContact can also return false and disable the contact
                    if (enabledA && enabledB && contactManager.BeginContact != null)
                    {
                        Enabled = contactManager.BeginContact(this);
                    }

                    // If the user disabled the contact (needed to exclude it in TOI solver) at any point by
                    // any of the callbacks, we need to mark it as not touching and call any separation
                    // callbacks for fixtures that didn't explicitly disable the collision.
                    if(!Enabled)
                    {
                        Flags &= ~ContactFlags.Touching;

                        if (enabledA && FixtureA.OnSeparation != null)
                        {
                            FixtureA.OnSeparation(FixtureA, FixtureB);
                        }
                        if (enabledB && FixtureB.OnSeparation != null)
                        {
                            FixtureB.OnSeparation(FixtureB, FixtureA);
                        }
                    }

#else
                    //Report the collision to both participants:
                    if (FixtureA.OnCollision != null)
                        Enabled = FixtureA.OnCollision(FixtureA, FixtureB, this);

                    //Reverse the order of the reported fixtures. The first fixture is always the one that the
                    //user subscribed to.
                    if (FixtureB.OnCollision != null)
                        Enabled = FixtureB.OnCollision(FixtureB, FixtureA, this);

                    //BeginContact can also return false and disable the contact
                    if (contactManager.BeginContact != null)
                        Enabled = contactManager.BeginContact(this);

                    //if the user disabled the contact (needed to exclude it in TOI solver), we also need to mark
                    //it as not touching.
                    if (Enabled == false)
                        Flags &= ~ContactFlags.Touching;
#endif
                }
            }
            else
            {
                if (touching == false)
                {
                    //Report the separation to both participants:
                    if (FixtureA != null && FixtureA.OnSeparation != null)
                        FixtureA.OnSeparation(FixtureA, FixtureB);

                    //Reverse the order of the reported fixtures. The first fixture is always the one that the
                    //user subscribed to.
                    if (FixtureB != null && FixtureB.OnSeparation != null)
                        FixtureB.OnSeparation(FixtureB, FixtureA);

                    if (contactManager.EndContact != null)
                        contactManager.EndContact(this);
                }
            }

            if (sensor)
                return;

            if (contactManager.PreSolve != null)
                contactManager.PreSolve(this, ref oldManifold);
        }
        public async Task Test1Async()
        {
            var     id    = Guid.NewGuid();
            var     id2   = Guid.NewGuid();
            Contact found = new Contact();

            Contact ct = new Contact()
            {
                ID       = id,
                Email    = "un imail",
                Name     = "Luis",
                LastName = "Tejeda"
            };

            ct.Address = new Address()
            {
                Street         = "Camino",
                ExternalNumber = "5150",
                InternalNumber = "803A",
                Location       = ""
            };

            Contact ct2 = new Contact()
            {
                ID       = id2,
                Email    = "un imail",
                Name     = "Alfredo",
                LastName = "Tejeda"
            };

            ct.Address = new Address()
            {
                Street         = "Camino",
                ExternalNumber = "5150",
                InternalNumber = "803A",
                Location       = ""
            };

            ContactManager mgr = new ContactManager();
            var            ser = JsonConvert.SerializeObject(new List <Contact>()
            {
                ct, ct2
            });
            await mgr.CreateAsync(new List <Contact>() { ct, ct2 }).ContinueWith(p =>
            {
                var contactFoundLoc = mgr.GetByIDAsync(id).Result;
                found = contactFoundLoc;
                Assert.NotNull(contactFoundLoc);


                var contactAgainRes = mgr.GetByMongoIDAsync(contactFoundLoc.MongoID).Result;
                var contactAgain    = contactAgainRes.FirstOrDefault();


                Assert.NotNull(contactAgain);
            }).ContinueWith(task =>
            {
                found.Name = "updated";
                mgr.UpdateAsync(new List <Contact>()
                {
                    found
                }).Wait();


                var contactFound = mgr.GetByIDAsync(id).Result;

                Assert.Equal("updated", contactFound.Name);


                var contactFound2 = mgr.GetByIDAsync(id2).Result;

                var res = mgr.DeleteByIDsAsync(new List <Guid>()
                {
                    contactFound.ID, contactFound2.ID
                }).Result;

                var contactFound3 = mgr.GetByIDAsync(id).Result;

                var contactFound4 = mgr.GetByIDAsync(id2).Result;
            });
        }
Пример #28
0
        public ActionResult Index(string namesurname, string email, string phone, string city, string subject, string body, string captcha, string departman)
        {
            try
            {
                if (Session["Captcha"] == null || Session["Captcha"].ToString() != captcha)
                {
                    TempData["captchaError"] = "Güvenlik doğrulmasını yanlış girdiniz, lütfen tekrar deneyiniz.";
                    return(RedirectToAction("Index"));
                }
                if (namesurname == String.Empty || email == String.Empty || subject == String.Empty || body == String.Empty)
                {
                    TempData["required"] = "true";
                    return(RedirectToAction("Index"));
                }

                //DB kaydet
                ContactHome contact = new ContactHome()
                {
                    FullName = namesurname, Email = email, City = city, Subject = subject, Body = body, Phone = phone
                };
                ContactManager.AddContactHome(contact);

                var mset  = MailManager.GetMailSettings();
                var msend = MailManager.GetMailUsersList(0);

                using (var client = new SmtpClient(mset.ServerHost, mset.Port))
                {
                    client.EnableSsl = mset.Security;//true;//burası düzeltilecek
                    //client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new NetworkCredential(mset.ServerMail, mset.Password);

                    var mail = new MailMessage();
                    mail.From = new MailAddress(mset.ServerMail, "Aston");
                    //mail.Attachments.Add(new Attachment(@"C:\Sonuc.pptx"));
                    foreach (var item in msend)
                    {
                        mail.To.Add(item.MailAddress);
                    }
                    mail.Subject    = subject;
                    mail.IsBodyHtml = true;
                    mail.Body       = "<h3>Gönderen:" + namesurname + " - " + email + "</h3>" +
                                      "<b>Tel: </b>" + phone +
                                      "<br><b>Şehir: </b>" + city +
                                      "<br><b>Departman: </b>" + departman +
                                      "<br><h3>Mesaj:</h3><p>" + body + "</p>";
                    //ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                    if (mail.To.Count > 0)
                    {
                        client.Send(mail);
                    }
                }
                TempData["sent"] = "true";
            }
            catch (Exception ex)
            {
                string message =
                    "Exception type " + ex.GetType() + Environment.NewLine +
                    "Exception message: " + ex.Message + Environment.NewLine +
                    "Stack trace: " + ex.StackTrace + Environment.NewLine;
                if (ex.InnerException != null)
                {
                    message += "---BEGIN InnerException--- " + Environment.NewLine +
                               "Exception type " + ex.InnerException.GetType() + Environment.NewLine +
                               "Exception message: " + ex.InnerException.Message + Environment.NewLine +
                               "Stack trace: " + ex.InnerException.StackTrace + Environment.NewLine +
                               "---END Inner Exception";
                }
                TempData["exception"] = message;
                TempData["sent"]      = "false";
            }

            ViewData["contact"] = ContactManager.GetContact("tr");
            return(View());
        }
Пример #29
0
    protected void PushLeadToProspect(object sender, EventArgs e)
    {
        //String[] forced_selected = new String[] { hf_contact_id.Value };
        //ContactManager.BindContacts(hf_company_id.Value, forced_selected); // rebind incase a merge occured on company update

        ContactManager.UpdateContacts(CompanyManager.CompanyID);

        CompanyManager.UpdateCompany();

        // Get valid selected ctc ids
        ArrayList selected_ctc_ids = ContactManager.SelectedValidContactIDs;
        ArrayList contact_ids      = ContactManager.ContactIDs;

        // Make sure all company info is correct
        if (CompanyManager.Turnover == null || CompanyManager.BizClikIndustry == null || (CompanyManager.CompanySize == null && CompanyManager.CompanySizeBracket == null) || CompanyManager.Country == null || CompanyManager.Website == null)
        {
            Util.PageMessageAlertify(this, "You must have Country, Industry, Turnover, Company Size and Website specified " +
                                     "to push this Lead to Prospect.<br/><br/>Click the company edit pencil and specify the required data.", "Data Required");
        }
        else if (dd_rep.SelectedItem.Text.Trim() == String.Empty || CompanyManager.CompanyName == null)
        {
            Util.PageMessageAlertify(this, "You must enter a company name and a rep!", "Rep and Company Name Required");
        }
        else if (CompanyManager.CompanyName.Length > 150)
        {
            Util.PageMessageAlertify(this, "The company name must be no more than 150 characters!", "Company Name Too Long");
        }
        else
        {
            String prosDueDate   = null;
            String prosLHDueDate = null;
            String PLevel        = null;
            if (datepicker_NewProspectDue.SelectedDate != null) // List Due
            {
                prosDueDate = Convert.ToDateTime(datepicker_NewProspectDue.SelectedDate).ToString("yyyy/MM/dd");
            }
            if (datepicker_NewProspectLHDue.SelectedDate != null) // List Due
            {
                prosLHDueDate = Convert.ToDateTime(datepicker_NewProspectLHDue.SelectedDate).ToString("yyyy/MM/dd");
            }

            if (dd_p1p2.SelectedItem.Text != String.Empty)
            {
                PLevel = dd_p1p2.SelectedItem.Text;
            }

            tb_notes.Text = Util.DateStamp(tb_notes.Text);
            // add username if not already exist
            if (tb_notes.Text.Trim() != String.Empty && !tb_notes.Text.EndsWith(")"))
            {
                tb_notes.Text += " (" + HttpContext.Current.User.Identity.Name + ")";
            }

            int  grade  = -1;
            bool insert = true;
            if (!Int32.TryParse(dd_grade.SelectedItem.Text, out grade))
            {
                insert = false;
                Util.PageMessage(this, "Please select a grade from 1-10!");
            }

            if (insert)
            {
                Util.SetRebindOnWindowClose(udp_ptp, true);

                if (dd_destination.Items.Count > 0 && dd_destination.SelectedItem != null)
                {
                    hf_team_id.Value = dd_destination.SelectedItem.Value;
                }

                // Ensure UTF8 encoding
                String notes = tb_notes.Text.Trim();
                if (!String.IsNullOrEmpty(notes))
                {
                    byte[] bytes = System.Text.Encoding.Default.GetBytes(notes);
                    notes = System.Text.Encoding.UTF8.GetString(bytes);
                }
                else
                {
                    notes = null;
                }

                String lha = tb_lha.Text.Trim();
                if (!String.IsNullOrEmpty(lha))
                {
                    byte[] bytes = System.Text.Encoding.Default.GetBytes(lha);
                    lha = System.Text.Encoding.UTF8.GetString(bytes);
                }
                else
                {
                    lha = null;
                }

                String benchmark_data = tb_benchmark_data.Text.Trim();
                if (!String.IsNullOrEmpty(benchmark_data))
                {
                    byte[] bytes = System.Text.Encoding.Default.GetBytes(benchmark_data);
                    benchmark_data = System.Text.Encoding.UTF8.GetString(bytes);
                }
                else
                {
                    benchmark_data = null;
                }

                String emails = null;
                if (dd_emails.SelectedItem.Value != String.Empty)
                {
                    emails = dd_emails.SelectedItem.Value;
                }

                String iqry = "INSERT INTO db_prospectreport " +
                              "(CompanyID,TeamID,CompanyName,Industry,SubIndustry,PLevel,Turnover,Employees,ListGeneratorFriendlyname,DateListDue,Emails," +
                              "Grade,OriginalGrade,Notes,IsHot,DateLetterHeadDue,LeadHookAngle,BenchmarkNotes) " +
                              "VALUES(@cpy_id, @team_id, @company, @industry, @sub_industry, @p1p2, @turnover, @employees, @rep, @list_due, @emails, @grade, @grade," +
                              "@notes,@hot,@lhduedate,@lha,@benchmark_data)";
                String[] pn = new String[] {
                    "@cpy_id",
                    "@team_id",
                    "@company",
                    "@industry",
                    "@sub_industry",
                    "@p1p2",
                    "@turnover",
                    "@employees",
                    "@rep",
                    "@list_due",
                    "@emails",
                    "@grade",
                    "@notes",
                    "@hot",
                    "@lhduedate",
                    "@lha",
                    "@benchmark_data"
                };
                Object[] pv = new Object[] {
                    CompanyManager.CompanyID,
                    hf_team_id.Value,
                    CompanyManager.CompanyName,
                    CompanyManager.BizClikIndustry,
                    CompanyManager.BizClikSubIndustry,
                    PLevel,
                    CompanyManager.Turnover + " " + CompanyManager.TurnoverDenomination,
                    CompanyManager.CompanySize,
                    dd_rep.SelectedItem.Text.Trim(),
                    prosDueDate,
                    emails,
                    grade,
                    notes,
                    cb_hot.Checked,
                    prosLHDueDate,
                    lha,
                    benchmark_data
                };

                try
                {
                    // Insert the Propsect first
                    long pros_id = SQL.Insert(iqry, pn, pv);

                    // Iterate ALL contacts and remove them from the Leads system
                    for (int i = 0; i < contact_ids.Count; i++)
                    {
                        String ctc_id = (String)contact_ids[i];

                        String[] ctc_pn = new String[] { "@ctc_id", "@user_id" };
                        Object[] ctc_pv = new Object[] { ctc_id, hf_user_id.Value };

                        // Remove Lead from Lead system [all projects for this user] (but ONLY for this user, people may share contacts in their Leads sheet)
                        String uqry = "UPDATE dbl_lead JOIN dbl_project ON dbl_lead.ProjectID = dbl_project.ProjectID SET dbl_lead.Active=0 WHERE ContactID=@ctc_id AND UserID=@user_id;";
                        SQL.Update(uqry, ctc_pn, ctc_pv);
                    }

                    // Iterate only SELECTED contacts and log them as Pushed To Prospect
                    String qry       = "SELECT LeadID FROM dbl_lead JOIN dbl_project ON dbl_lead.ProjectID = dbl_project.ProjectID WHERE ContactID=@ctc_id AND UserID=@user_id";
                    String pros_uqry = "UPDATE dbl_lead SET Prospect=1, DateMadeProspect=CURRENT_TIMESTAMP WHERE LeadID=@lead_id";
                    for (int i = 0; i < selected_ctc_ids.Count; i++)
                    {
                        String ctc_id = (String)selected_ctc_ids[i];

                        String[] ctc_pn = new String[] { "@ctc_id", "@user_id", "@prospect_id" };
                        Object[] ctc_pv = new Object[] { ctc_id, hf_user_id.Value, pros_id.ToString() };

                        // LOG: Get id of leads for this user whose contact id is selected as push to prospect
                        DataTable dt_leads = SQL.SelectDataTable(qry, ctc_pn, ctc_pv);
                        for (int j = 0; j < dt_leads.Rows.Count; j++)
                        {
                            String this_lead_id = dt_leads.Rows[j]["LeadID"].ToString();
                            SQL.Update(pros_uqry, "@lead_id", this_lead_id);
                            LeadsUtil.AddLeadHistoryEntry(this_lead_id, "Pushed to Prospect.");
                        }

                        // Add to contact context table
                        iqry = "INSERT INTO db_contact_system_context (ContactID, TargetSystemID, TargetSystem) VALUES (@ctc_id, @prospect_id, 'Prospect')";
                        SQL.Insert(iqry, ctc_pn, ctc_pv);
                    }

                    // Dashboard Log
                    Util.WriteLogWithDetails("New prospect (" + CompanyManager.CompanyName + ") added in " + hf_office.Value + " - " + hf_team_name.Value + ".", "prospectreports_log");

                    if (cb_view_writeup.Checked)
                    {
                        System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "OpenWindow", "window.open('/dashboard/prospectreports/prospectwriteup.aspx?id=" + pros_id + "','_newtab');", true);
                    }

                    Util.CloseRadWindowFromUpdatePanel(this, CompanyManager.CompanyName, false);
                }
                catch (Exception r)
                {
                    if (Util.IsTruncateError(this, r))
                    {
                    }
                    else
                    {
                        Util.PageMessage(this, "An error occured, please try again.");
                        Util.WriteLogWithDetails("Error adding prospect " + r.Message + " " + r.StackTrace, "prospectreports_log");
                    }
                }
            }
        }
    }
 public ContactIdentificationRepository()
 {
     contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
 }
Пример #31
0
        protected void saveContact()
        {
            bool isNewContact = false;
            int  contactID    = Convert.ToInt32(ViewState["ContactID"]);

            Contact      contact      = null;
            ClaimContact claimContact = null;

            lblMessage.Text = string.Empty;

            if (contactID == 0)
            {
                // new contact
                contact = new Contact();

                contact.ClientID = Core.SessionHelper.getClientId();

                isNewContact = true;
            }
            else
            {
                contact = ContactManager.Get(contactID);
            }

            contact.FirstName   = txtFirstName.Text;
            contact.LastName    = txtLastName.Text;
            contact.ContactName = txtFirstName.Text + " " + txtLastName.Text;

            contact.Phone          = txtContactPhone.Text;
            contact.Email          = txtContactEmail.Text;
            contact.Phone          = txtContactPhone.Text;
            contact.Mobile         = txtMobilePhone.Text;
            contact.ContactTitle   = txtContactTile.Text;
            contact.DepartmentName = txtDepartmentName.Text;
            contact.IsPrimary      = cbxPrimary.Checked;
            contact.Fax            = txtContactFax.Text;
            contact.CompanyName    = txtCompanyName.Text.Trim();

            if (ddlContactType.SelectedIndex > 0)
            {
                contact.CategoryID = Convert.ToInt32(ddlContactType.SelectedValue);
            }
            else
            {
                contact.CategoryID = null;
            }

            contact.Address1 = txtAddress1.Text;
            contact.Address2 = txtAddress2.Text;

            if (ddlState.SelectedIndex > 0)
            {
                contact.StateID = Convert.ToInt32(ddlState.SelectedValue);
            }

            if (ddlCity.SelectedIndex > 0)
            {
                contact.CityID = Convert.ToInt32(ddlCity.SelectedValue);
            }

            if (ddlLossZip.SelectedIndex > 0)
            {
                contact.ZipCodeID = Convert.ToInt32(ddlLossZip.SelectedValue);
            }



            try {
                if (isNewContact)
                {
                    using (TransactionScope scope = new TransactionScope()) {
                        // save contact to contact table
                        contact = ContactManager.Save(contact);

                        claimContact = new ClaimContact();

                        claimContact.ClaimID   = this.claimID;
                        claimContact.ContactID = contact.ContactID;

                        // save contact reference for claim
                        claimContact = ClaimContactManager.Save(claimContact);

                        // complete transaction
                        scope.Complete();
                    }
                }
                else
                {
                    // save contact to contact table
                    contact = ContactManager.Save(contact);
                }

                lblMessage.Text     = "Contact saved successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Contact not saved.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
            finally {
                bindData(this.claimID);
            }
        }
Пример #32
0
 public void OnSearch(ContactManager _source, SearchResults _searchResults, AsynchronousOperation _asyncOperation)
 {
 }
Пример #33
0
    protected void BindProspectInfo()
    {
        String qry = "SELECT PLevel, ListGeneratorFriendlyname, Emails, Grade, Notes, IsHot, pr.DateAdded, DateListDue, DateLetterHeadDue, LeadHookAngle, BenchmarkNotes, " + // prospect info
                     "cpy.CompanyName, cpy.CompanyID, cpy.Industry, cpy.SubIndustry, cpy.Turnover, cpy.Employees, cpy.Phone, cpy.Website " +                                  // company info
                     "FROM db_prospectreport pr, db_company cpy WHERE pr.CompanyID = cpy.CompanyID AND ProspectID=@pros_id";
        DataTable dt_pros_info = SQL.SelectDataTable(qry, "@pros_id", hf_pros_id.Value);

        if (dt_pros_info.Rows.Count > 0)
        {
            lbl_prospect.Text = "Currently editing <b>" + dt_pros_info.Rows[0]["CompanyName"] + "</b>";

            // LH due
            String lh_due = dt_pros_info.Rows[0]["DateLetterHeadDue"].ToString();
            if (lh_due.Trim() != String.Empty)
            {
                DateTime dt_lh_due = new DateTime();
                if (DateTime.TryParse(lh_due, out dt_lh_due))
                {
                    dp_lh_due.SelectedDate = dt_lh_due;
                }
            }
            // List due
            String list_due = dt_pros_info.Rows[0]["DateListDue"].ToString();
            if (list_due.Trim() != String.Empty)
            {
                DateTime dt_list_due = new DateTime();
                if (DateTime.TryParse(list_due, out dt_list_due))
                {
                    dp_list_due.SelectedDate = dt_list_due;
                }
            }

            // Rep
            String rep     = dt_pros_info.Rows[0]["ListGeneratorFriendlyname"].ToString();
            int    rep_idx = dd_rep.Items.IndexOf(dd_rep.Items.FindByText(rep));
            if (rep_idx == -1)
            {
                dd_rep.Items.Insert(0, new ListItem(rep)); // in case user is no longer employed
                dd_rep.SelectedIndex = 0;
            }
            else
            {
                dd_rep.SelectedIndex = rep_idx;
            }

            int idx = dd_emails.Items.IndexOf(dd_emails.Items.FindByValue(dt_pros_info.Rows[0]["Emails"].ToString()));
            if (idx != -1)
            {
                dd_emails.SelectedIndex = idx;
            }

            dd_p1_p2.Text          = dt_pros_info.Rows[0]["PLevel"].ToString();
            dd_grade.Text          = dt_pros_info.Rows[0]["Grade"].ToString();
            tb_notes.Text          = dt_pros_info.Rows[0]["Notes"].ToString();
            tb_lha.Text            = dt_pros_info.Rows[0]["LeadHookAngle"].ToString();
            tb_benchmark_data.Text = dt_pros_info.Rows[0]["BenchmarkNotes"].ToString();

            // Bind company
            hf_cpy_id.Value = dt_pros_info.Rows[0]["CompanyID"].ToString();
            CompanyManager.BindCompany(hf_cpy_id.Value);

            // Bind contacts
            DateTime ContactContextCutOffDate = new DateTime(2017, 4, 6);
            DateTime ProspectAdded            = Convert.ToDateTime(dt_pros_info.Rows[0]["DateAdded"].ToString());
            if (ProspectAdded >= ContactContextCutOffDate)
            {
                ContactManager.TargetSystemID = hf_pros_id.Value;
            }
            ContactManager.BindContacts(hf_cpy_id.Value);
        }
    }
Пример #34
0
 protected override void Initialize(RequestContext requestContext)
 {
     base.Initialize(requestContext);
     contactManager = new ContactManager(UnitOfWork);
 }
Пример #35
0
    protected void UpdateProspect(object sender, EventArgs e)
    {
        bool update = true;

        // Check rep
        if (dd_rep.Items.Count > 0 && dd_rep.SelectedItem != null && dd_rep.SelectedItem.Text.Trim() == String.Empty)
        {
            Util.PageMessage(this, "You must select a rep!");
            update = false;
        }

        // pros_id
        int pros_id = 0;

        if (hf_pros_id.Value.Trim() == String.Empty)
        {
            update = false;
        }
        else if (!Int32.TryParse(hf_pros_id.Value.Trim(), out pros_id))
        {
            update = false;
        }

        // list_due
        String   list_due    = null;
        DateTime dt_list_due = new DateTime();

        if (dp_list_due.SelectedDate != null)
        {
            if (DateTime.TryParse(dp_list_due.SelectedDate.ToString(), out dt_list_due))
            {
                list_due = dt_list_due.ToString("yyyy/MM/dd");
            }
        }
        // lh due
        String   lh_due    = null;
        DateTime dt_lh_due = new DateTime();

        if (dp_lh_due.SelectedDate != null)
        {
            if (DateTime.TryParse(dp_lh_due.SelectedDate.ToString(), out dt_lh_due))
            {
                lh_due = dt_lh_due.ToString("yyyy/MM/dd");
            }
        }

        // date_moved_from_p3, when changing from p3
        String date_moved_from_p3 = null;
        String qry     = "SELECT PLevel FROM db_prospectreport WHERE ProspectID=@pros_id";
        String p_level = SQL.SelectString(qry, "PLevel", "@pros_id", pros_id);

        if (p_level == "3" && (dd_p1_p2.SelectedItem.Text == "1" || dd_p1_p2.SelectedItem.Text == "2"))
        {
            date_moved_from_p3 = DateTime.Now.ToString("yyyy/MM/dd HH/mm/ss");
        }

        //notes
        tb_notes.Text = Util.DateStamp(tb_notes.Text);
        // add username if not already exist
        if (tb_notes.Text.Trim() != String.Empty && !tb_notes.Text.EndsWith(")"))
        {
            tb_notes.Text += " (" + HttpContext.Current.User.Identity.Name + ")";
        }

        int grade = -1;

        if (!Int32.TryParse(dd_grade.SelectedItem.Text, out grade))
        {
            update = false;
            Util.PageMessage(this, "Please select a grade from 1-10!");
        }

        String PLevel = null;

        if (dd_p1_p2.SelectedItem.Text != String.Empty)
        {
            PLevel = dd_p1_p2.SelectedItem.Text;
        }

        String emails = null;

        if (dd_emails.SelectedItem.Value != String.Empty)
        {
            emails = dd_emails.SelectedItem.Value;
        }

        if (update)
        {
            try
            {
                // Update contacts
                ContactManager.UpdateContacts(hf_cpy_id.Value);

                // Update company
                CompanyManager.UpdateCompany(hf_cpy_id.Value);

                String notes = null;
                if (!String.IsNullOrEmpty(tb_notes.Text.Trim()))
                {
                    notes = Util.ConvertStringToUTF8(tb_notes.Text.Trim());
                }

                String benchmark_data = null;
                if (!String.IsNullOrEmpty(tb_benchmark_data.Text.Trim()))
                {
                    benchmark_data = Util.ConvertStringToUTF8(tb_benchmark_data.Text.Trim());
                }

                String lha = null;
                if (!String.IsNullOrEmpty(tb_lha.Text.Trim()))
                {
                    lha = Util.ConvertStringToUTF8(tb_lha.Text.Trim());
                }

                // Update prospect
                String uqry = "UPDATE db_prospectreport SET " +
                              "CompanyName=@company, " +
                              "Industry=@industry," +
                              "SubIndustry=@sub_industry," +
                              "PLevel=@p1p2, " +
                              "DateMovedFromP3=CASE WHEN @date_moved_from_p3 IS NOT NULL THEN @date_moved_from_p3 ELSE DateMovedFromP3 END, " +
                              "Turnover=@turnover, " +
                              "Employees=@employees," +
                              "ListGeneratorFriendlyname=@rep, " +
                              "DateListDue=@list_due, " +
                              "Emails=@emails, " +
                              "Grade=@grade, " +
                              "Notes=@notes, " +
                              "DateLetterHeadDue=@lh_due_date, " +
                              "LeadHookAngle=@lha, BenchmarkNotes=@benchmark_data, LastUpdated=CURRENT_TIMESTAMP " +
                              "WHERE ProspectID=@pros_id";
                String[] pn = new String[] { "@company", "@industry", "@sub_industry", "@p1p2", "@date_moved_from_p3", "@turnover", "@employees", "@rep", "@list_due",
                                             "@emails", "@grade", "@notes", "@lh_due_date", "@lha", "@benchmark_data", "@pros_id" };
                Object[] pv = new Object[] {
                    CompanyManager.CompanyName,
                    CompanyManager.BizClikIndustry,
                    CompanyManager.BizClikSubIndustry,
                    PLevel,
                    date_moved_from_p3,
                    CompanyManager.Turnover + " " + CompanyManager.TurnoverDenomination,
                    CompanyManager.CompanySize,
                    dd_rep.SelectedItem.Text,
                    list_due,
                    emails,
                    grade,
                    notes,
                    lh_due,
                    lha,
                    benchmark_data,
                    pros_id
                };
                SQL.Update(uqry, pn, pv);

                String team_name = Util.GetUserTeamNameFromId(hf_team_id.Value);
                Util.WriteLogWithDetails("Prospect '" + CompanyManager.CompanyName + "' successfully updated in " + hf_office.Value + " - " + team_name + ".", "prospectreports_log");

                Util.CloseRadWindow(this, CompanyManager.CompanyName, false);
            }
            catch (Exception r)
            {
                //Util.Debug(r.Message + Environment.NewLine + r.StackTrace);
                if (Util.IsTruncateError(this, r))
                {
                }
                else
                {
                    Util.WriteLogWithDetails(r.Message + Environment.NewLine + r.StackTrace + Environment.NewLine + "<b>Prospect ID:</b> " + pros_id, "prospectreports_log");
                    Util.PageMessage(this, "An error occured, please try again.");
                }
            }
        }
    }
Пример #36
0
        /// <summary>
        /// Update the contact manifold and touching status.
        /// Note: do not assume the fixture AABBs are overlapping or are valid.
        /// </summary>
        /// <param name="contactManager">The contact manager.</param>
        internal void Update(ContactManager contactManager)
        {
            Manifold oldManifold = Manifold;

            // Re-enable this contact.
            Flags |= ContactFlags.Enabled;

            bool touching;
            bool wasTouching = (Flags & ContactFlags.Touching) == ContactFlags.Touching;

            bool sensorA = FixtureA.IsSensor;
            bool sensorB = FixtureB.IsSensor;
            bool sensor = sensorA || sensorB;

            Body bodyA = FixtureA.Body;
            Body bodyB = FixtureB.Body;
            Transform xfA;
            bodyA.GetTransform(out xfA);
            Transform xfB;
            bodyB.GetTransform(out xfB);

            // Is this contact a sensor?
            if (sensor)
            {
                Shape shapeA = FixtureA.Shape;
                Shape shapeB = FixtureB.Shape;
                touching = AABB.TestOverlap(shapeA, ChildIndexA, shapeB, ChildIndexB, ref xfA, ref xfB);

                // Sensors don't generate manifolds.
                Manifold.PointCount = 0;
            }
            else
            {
                Evaluate(ref Manifold, ref xfA, ref xfB);
                touching = Manifold.PointCount > 0;

                // Match old contact ids to new contact ids and copy the
                // stored impulses to warm start the solver.
                for (int i = 0; i < Manifold.PointCount; ++i)
                {
                    ManifoldPoint mp2 = Manifold.Points[i];
                    mp2.NormalImpulse = 0.0f;
                    mp2.TangentImpulse = 0.0f;
                    ContactID id2 = mp2.Id;
                    bool found = false;

                    for (int j = 0; j < oldManifold.PointCount; ++j)
                    {
                        ManifoldPoint mp1 = oldManifold.Points[j];

                        if (mp1.Id.Key == id2.Key)
                        {
                            mp2.NormalImpulse = mp1.NormalImpulse;
                            mp2.TangentImpulse = mp1.TangentImpulse;
                            found = true;
                            break;
                        }
                    }
                    if (found == false)
                    {
                        mp2.NormalImpulse = 0.0f;
                        mp2.TangentImpulse = 0.0f;
                    }

                    Manifold.Points[i] = mp2;
                }

                if (touching != wasTouching)
                {
                    bodyA.Awake = true;
                    bodyB.Awake = true;
                }
            }

            if (touching)
            {
                Flags |= ContactFlags.Touching;
            }
            else
            {
                Flags &= ~ContactFlags.Touching;
            }

            if (wasTouching == false && touching)
            {
                // Report the collision to both participants:
                if (FixtureA.OnCollision != null)
                    Enabled = FixtureA.OnCollision(FixtureA, FixtureB, this);

                // Reverse the order of the reported fixtures. The first fixture is always the one that the
                // user subscribed to.
                if (FixtureB.OnCollision != null)
                    Enabled = FixtureB.OnCollision(FixtureB, FixtureA, this);

                // if the user disabled the contact (needed to exclude it in TOI solver), we also need to mark
                // it as not touching.
                if (Enabled == false)
                    Flags &= ~ContactFlags.Touching;

                if (contactManager.BeginContact != null)
                    contactManager.BeginContact(this);
            }

            if (wasTouching && touching == false)
            {
                // Report the separation to both participants:
                if (FixtureA.OnSeparation != null)
                    FixtureA.OnSeparation(FixtureA, FixtureB);

                // Reverse the order of the reported fixtures. The first fixture is always the one that the
                // user subscribed to.
                if (FixtureB.OnSeparation != null)
                    FixtureB.OnSeparation(FixtureB, FixtureA);

                if (contactManager.EndContact != null)
                    contactManager.EndContact(this);
            }

            if (sensor == false)
            {
                if (contactManager.PreSolve != null)
                    contactManager.PreSolve(this, ref oldManifold);
            }
        }
Пример #37
0
        private async Task ParseTagContents(NdefMessage ndefMessage, StringBuilder tagContents)
        {
            // Loop over all records contained in the NDEF message
            foreach (NdefRecord record in ndefMessage)
            {
                // --------------------------------------------------------------------------
                // Print generic information about the record
                if (record.Id != null && record.Id.Length > 0)
                {
                    // Record ID (if present)
                    tagContents.AppendFormat("Id: {0}\n", Encoding.UTF8.GetString(record.Id, 0, record.Id.Length));
                }
                // Record type name, as human readable string
                tagContents.AppendFormat("Type name: {0}\n", ConvertTypeNameFormatToString(record.TypeNameFormat));
                // Record type
                if (record.Type != null && record.Type.Length > 0)
                {
                    tagContents.AppendFormat("Record type: {0}\n",
                                             Encoding.UTF8.GetString(record.Type, 0, record.Type.Length));
                }

                // --------------------------------------------------------------------------
                // Check the type of each record
                // Using 'true' as parameter for CheckSpecializedType() also checks for sub-types of records,
                // e.g., it will return the SMS record type if a URI record starts with "sms:"
                // If using 'false', a URI record will always be returned as Uri record and its contents won't be further analyzed
                // Currently recognized sub-types are: SMS, Mailto, Tel, Nokia Accessories, NearSpeak, WpSettings
                var specializedType = record.CheckSpecializedType(true);

                if (specializedType == typeof(NdefMailtoRecord))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract Mailto record info
                    var mailtoRecord = new NdefMailtoRecord(record);
                    tagContents.Append("-> Mailto record\n");
                    tagContents.AppendFormat("Address: {0}\n", mailtoRecord.Address);
                    tagContents.AppendFormat("Subject: {0}\n", mailtoRecord.Subject);
                    tagContents.AppendFormat("Body: {0}\n", mailtoRecord.Body);
                }
                else if (specializedType == typeof(NdefUriRecord))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract URI record info
                    var uriRecord = new NdefUriRecord(record);
                    tagContents.Append("-> URI record\n");
                    tagContents.AppendFormat("URI: {0}\n", uriRecord.Uri);
                }
                else if (specializedType == typeof(NdefSpRecord))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract Smart Poster info
                    var spRecord = new NdefSpRecord(record);
                    tagContents.Append("-> Smart Poster record\n");
                    tagContents.AppendFormat("URI: {0}", spRecord.Uri);
                    tagContents.AppendFormat("Titles: {0}", spRecord.TitleCount());
                    if (spRecord.TitleCount() > 1)
                    {
                        tagContents.AppendFormat("1. Title: {0}", spRecord.Titles[0].Text);
                    }
                    tagContents.AppendFormat("Action set: {0}", spRecord.ActionInUse());
                    // You can also check the action (if in use by the record),
                    // mime type and size of the linked content.
                }
                else if (specializedType == typeof(NdefVcardRecordBase))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract business card info
                    var vcardRecord = new NdefVcardRecord(record);
                    tagContents.Append("-> Business Card record" + Environment.NewLine);
                    var contact = vcardRecord.ContactData;

                    // Contact has phone or email info set? Use contact manager to show the contact card
                    await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        if (contact.Emails.Any() || contact.Phones.Any())
                        {
                            var rect = GetElementRect(StatusOutput);
                            ContactManager.ShowContactCard(contact, rect, Placement.Below);
                        }
                        else
                        {
                            // No phone or email set - contact manager would not show the contact card.
                            // -> parse manually
                            tagContents.AppendFormat("Name: {0}\n", contact.DisplayName);
                            tagContents.Append("[not parsing other values in the demo app]");
                        }
                    });
                }
                else if (specializedType == typeof(NdefLaunchAppRecord))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract LaunchApp record info
                    var launchAppRecord = new NdefLaunchAppRecord(record);
                    tagContents.Append("-> LaunchApp record" + Environment.NewLine);
                    if (!string.IsNullOrEmpty(launchAppRecord.Arguments))
                    {
                        tagContents.AppendFormat("Arguments: {0}\n", launchAppRecord.Arguments);
                    }
                    if (launchAppRecord.PlatformIds != null)
                    {
                        foreach (var platformIdTuple in launchAppRecord.PlatformIds)
                        {
                            if (platformIdTuple.Key != null)
                            {
                                tagContents.AppendFormat("Platform: {0}\n", platformIdTuple.Key);
                            }
                            if (platformIdTuple.Value != null)
                            {
                                tagContents.AppendFormat("App ID: {0}\n", platformIdTuple.Value);
                            }
                        }
                    }
                }
                else if (specializedType == typeof(NdefMimeImageRecordBase))
                {
                    // --------------------------------------------------------------------------
                    // Convert and extract Image record info
                    var imgRecord = new NdefMimeImageRecord(record);
                    tagContents.Append("-> MIME / Image record" + Environment.NewLine);
                    _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => SetStatusImage(await imgRecord.GetImageAsBitmap()));
                }
                else
                {
                    // Other type, not handled by this demo
                    tagContents.Append("NDEF record not parsed by this demo app" + Environment.NewLine);
                }
            }
        }
Пример #38
0
        /// <summary>
        /// checks for collisions between two Fixtures. Note that the first Fixture must have a Circle/PolygonShape and one of the Fixtures must be
        /// static.
        /// </summary>
        /// <returns><c>true</c>, if fixtures was collided, <c>false</c> otherwise.</returns>
        /// <param name="fixtureA">Fixture a.</param>
        /// <param name="transformA">Transform a.</param>
        /// <param name="fixtureB">Fixture b.</param>
        /// <param name="transformB">Transform b.</param>
        /// <param name="result">Result.</param>
        public static bool collideFixtures(Fixture fixtureA, ref FSTransform transformA, Fixture fixtureB, ref FSTransform transformB, out FSCollisionResult result)
        {
            result         = new FSCollisionResult();
            result.fixture = fixtureB;

            // we need at least one static fixture
            if (!fixtureA.body.isStatic && !fixtureB.body.isStatic)
            {
                // if the body is dyanmic and asleep wake it up
                if (fixtureB.body.isDynamic && !fixtureB.body.isAwake)
                {
                    fixtureB.body.isAwake = true;
                }
                return(false);
            }

            // check normal collision filtering
            if (!ContactManager.shouldCollide(fixtureA, fixtureB))
            {
                return(false);
            }

            // check user filtering
            if (fixtureA.body.world.contactManager.onContactFilter != null && !fixtureA.body.world.contactManager.onContactFilter(fixtureA, fixtureB))
            {
                return(false);
            }

            // we only handle Circle or Polygon collisions
            if (fixtureA.shape is CircleShape)
            {
                if (fixtureB.shape is CircleShape)
                {
                    return(collideCircles(fixtureA.shape as CircleShape, ref transformA, fixtureB.shape as CircleShape, ref transformB, out result));
                }

                if (fixtureB.shape is PolygonShape)
                {
                    return(collidePolygonCircle(fixtureB.shape as PolygonShape, ref transformB, fixtureA.shape as CircleShape, ref transformA, out result));
                }

                if (fixtureB.shape is EdgeShape)
                {
                    return(collideEdgeAndCircle(fixtureB.shape as EdgeShape, ref transformB, fixtureA.shape as CircleShape, ref transformA, out result));
                }

                if (fixtureB.shape is ChainShape)
                {
                    var chain = fixtureB.shape as ChainShape;
                    for (var i = 0; i < chain.childCount; i++)
                    {
                        var edge = chain.getChildEdge(i);
                        if (collideEdgeAndCircle(edge, ref transformB, fixtureA.shape as CircleShape, ref transformA, out result))
                        {
                            return(true);
                        }
                    }
                }
            }

            if (fixtureA.shape is PolygonShape)
            {
                if (fixtureB.shape is CircleShape)
                {
                    var res = collidePolygonCircle(fixtureA.shape as PolygonShape, ref transformA, fixtureB.shape as CircleShape, ref transformB, out result);
                    result.invertResult();
                    return(res);
                }

                if (fixtureB.shape is PolygonShape)
                {
                    return(collidePolygons(fixtureA.shape as PolygonShape, ref transformA, fixtureB.shape as PolygonShape, ref transformB, out result));
                }

                if (fixtureB.shape is EdgeShape)
                {
                    return(collideEdgeAndPolygon(fixtureB.shape as EdgeShape, ref transformB, fixtureA.shape as PolygonShape, ref transformA, out result));
                }

                if (fixtureB.shape is ChainShape)
                {
                    var chain = fixtureB.shape as ChainShape;
                    for (var i = 0; i < chain.childCount; i++)
                    {
                        var edge = chain.getChildEdge(i);
                        if (collideEdgeAndPolygon(edge, ref transformB, fixtureA.shape as PolygonShape, ref transformA, out result))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #39
0
 public virtual void SaveAll(ContactManager.UserCollection userCollection)
 {
     ContactManager.UserCollection userCollection1 = userCollection;
     userCollection1.SaveAll();
 }
Пример #40
0
 public AccountController(ContactManager userManager, ApplicationSignInManager signInManager)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
 }
Пример #41
0
        public Contact GetContact(int id)
        {
            var contactManager = new ContactManager();

            return(contactManager.GetContact(id));
        }
 private void InitializeContact()
 {
     contactManager = (ContactManager)Factory.CreateObject("tracking/contactManager", true);
     contact = Tracker.Current.Contact;
 }
Пример #43
0
        /// <summary>
        /// Update the contact manifold and touching status.
        /// Note: do not assume the fixture AABBs are overlapping or are valid.
        /// </summary>
        /// <param name="contactManager">The contact manager.</param>
        internal void Update(ContactManager contactManager)
        {
            Manifold oldManifold = Manifold;

            // Re-enable this contact.
            Flags |= ContactFlags.Enabled;

            bool touching;
            bool wasTouching = (Flags & ContactFlags.Touching) == ContactFlags.Touching;

            bool sensor = FixtureA.IsSensor || FixtureB.IsSensor;

            Body bodyA = FixtureA.Body;
            Body bodyB = FixtureB.Body;

            // Is this contact a sensor?
            if (sensor)
            {
                Shape shapeA = FixtureA.Shape;
                Shape shapeB = FixtureB.Shape;
                touching = AABB.TestOverlap(shapeA, ChildIndexA, shapeB, ChildIndexB, ref bodyA.Xf, ref bodyB.Xf);

                // Sensors don't generate manifolds.
                Manifold.PointCount = 0;
            }
            else
            {
                Evaluate(ref Manifold, ref bodyA.Xf, ref bodyB.Xf);
                touching = Manifold.PointCount > 0;

                // Match old contact ids to new contact ids and copy the
                // stored impulses to warm start the solver.
                for (int i = 0; i < Manifold.PointCount; ++i)
                {
                    ManifoldPoint mp2 = Manifold.Points[i];
                    mp2.NormalImpulse  = 0.0f;
                    mp2.TangentImpulse = 0.0f;
                    ContactID id2   = mp2.Id;
                    bool      found = false;

                    for (int j = 0; j < oldManifold.PointCount; ++j)
                    {
                        ManifoldPoint mp1 = oldManifold.Points[j];

                        if (mp1.Id.Key == id2.Key)
                        {
                            mp2.NormalImpulse  = mp1.NormalImpulse;
                            mp2.TangentImpulse = mp1.TangentImpulse;
                            found = true;
                            break;
                        }
                    }
                    if (found == false)
                    {
                        mp2.NormalImpulse  = 0.0f;
                        mp2.TangentImpulse = 0.0f;
                    }

                    Manifold.Points[i] = mp2;
                }

                if (touching != wasTouching)
                {
                    bodyA.Awake = true;
                    bodyB.Awake = true;
                }
            }

            if (touching)
            {
                Flags |= ContactFlags.Touching;
            }
            else
            {
                Flags &= ~ContactFlags.Touching;
            }

            if (wasTouching == false && touching)
            {
                //Report the collision to both participants:
                if (FixtureA.OnCollision != null)
                {
                    Enabled = FixtureA.OnCollision(FixtureA, FixtureB, this);
                }

                //Reverse the order of the reported fixtures. The first fixture is always the one that the
                //user subscribed to.
                if (FixtureB.OnCollision != null)
                {
                    Enabled = FixtureB.OnCollision(FixtureB, FixtureA, this);
                }

                //BeginContact can also return false and disable the contact
                if (contactManager.BeginContact != null)
                {
                    Enabled = contactManager.BeginContact(this);
                }

                //if the user disabled the contact (needed to exclude it in TOI solver), we also need to mark
                //it as not touching.
                if (Enabled == false)
                {
                    Flags &= ~ContactFlags.Touching;
                }
            }

            if (wasTouching && touching == false)
            {
                //Report the separation to both participants:
                if (FixtureA != null && FixtureA.OnSeparation != null)
                {
                    FixtureA.OnSeparation(FixtureA, FixtureB);
                }

                //Reverse the order of the reported fixtures. The first fixture is always the one that the
                //user subscribed to.
                if (FixtureB != null && FixtureB.OnSeparation != null)
                {
                    FixtureB.OnSeparation(FixtureB, FixtureA);
                }

                if (contactManager.EndContact != null)
                {
                    contactManager.EndContact(this);
                }
            }

            if (sensor)
            {
                return;
            }

            if (contactManager.PreSolve != null)
            {
                contactManager.PreSolve(this, ref oldManifold);
            }
        }
 public virtual void SaveAll(ContactManager.ContactSourceCollection contactSourceCollection)
 {
     ContactManager.ContactSourceCollection contactSourceCollection1 = contactSourceCollection;
     contactSourceCollection1.SaveAll();
 }
Пример #45
0
        /// <summary>
        /// Update the contact manifold and touching status.
        /// Note: do not assume the fixture AABBs are overlapping or are valid.
        /// </summary>
        /// <param name="contactManager">The contact manager.</param>
        internal void Update(ContactManager contactManager)
        {
            Body bodyA = FixtureA.Body;
            Body bodyB = FixtureB.Body;

            if (FixtureA == null || FixtureB == null)
                return;

            Manifold oldManifold = Manifold;

            // Re-enable this contact.
            Enabled = true;

            bool touching;
            bool wasTouching = IsTouching;

            bool sensor = FixtureA.IsSensor || FixtureB.IsSensor;

            // Is this contact a sensor?
            if (sensor)
            {
                Shape shapeA = FixtureA.Shape;
                Shape shapeB = FixtureB.Shape;
                touching = Collision.Collision.TestOverlap(shapeA, ChildIndexA, shapeB, ChildIndexB, ref bodyA._xf, ref bodyB._xf);

                // Sensors don't generate manifolds.
                Manifold.PointCount = 0;
            }
            else
            {
                Evaluate(ref Manifold, ref bodyA._xf, ref bodyB._xf);
                touching = Manifold.PointCount > 0;

                // Match old contact ids to new contact ids and copy the
                // stored impulses to warm start the solver.
                for (int i = 0; i < Manifold.PointCount; ++i)
                {
                    ManifoldPoint mp2 = Manifold.Points[i];
                    mp2.NormalImpulse = 0.0f;
                    mp2.TangentImpulse = 0.0f;
                    ContactID id2 = mp2.Id;

                    for (int j = 0; j < oldManifold.PointCount; ++j)
                    {
                        ManifoldPoint mp1 = oldManifold.Points[j];

                        if (mp1.Id.Key == id2.Key)
                        {
                            mp2.NormalImpulse = mp1.NormalImpulse;
                            mp2.TangentImpulse = mp1.TangentImpulse;
                            break;
                        }
                    }

                    Manifold.Points[i] = mp2;
                }

                if (touching != wasTouching)
                {
                    bodyA.Awake = true;
                    bodyB.Awake = true;
                }
            }

            IsTouching = touching;

            if (wasTouching == false)
            {
                if (touching)
                {
                    if (Settings.AllCollisionCallbacksAgree)
                    {
                        bool enabledA = true, enabledB = true;

                        // Report the collision to both participants. Track which ones returned true so we can
                        // later call OnSeparation if the contact is disabled for a different reason.
                        if (FixtureA.OnCollision != null)
                            foreach (OnCollisionEventHandler handler in FixtureA.OnCollision.GetInvocationList())
                                enabledA = handler(FixtureA, FixtureB, this) && enabledA;

                        // Reverse the order of the reported fixtures. The first fixture is always the one that the
                        // user subscribed to.
                        if (FixtureB.OnCollision != null)
                            foreach (OnCollisionEventHandler handler in FixtureB.OnCollision.GetInvocationList())
                                enabledB = handler(FixtureB, FixtureA, this) && enabledB;

                        Enabled = enabledA && enabledB;

                        // BeginContact can also return false and disable the contact
                        if (enabledA && enabledB && contactManager.BeginContact != null)
                            Enabled = contactManager.BeginContact(this);
                    }
                    else
                    {
                        //Report the collision to both participants:
                        if (FixtureA.OnCollision != null)
                            foreach (OnCollisionEventHandler handler in FixtureA.OnCollision.GetInvocationList())
                                Enabled = handler(FixtureA, FixtureB, this);

                        //Reverse the order of the reported fixtures. The first fixture is always the one that the
                        //user subscribed to.
                        if (FixtureB.OnCollision != null)
                            foreach (OnCollisionEventHandler handler in FixtureB.OnCollision.GetInvocationList())
                                Enabled = handler(FixtureB, FixtureA, this);

                        //BeginContact can also return false and disable the contact
                        if (contactManager.BeginContact != null)
                            Enabled = contactManager.BeginContact(this);
                    }

                    // If the user disabled the contact (needed to exclude it in TOI solver) at any point by
                    // any of the callbacks, we need to mark it as not touching and call any separation
                    // callbacks for fixtures that didn't explicitly disable the collision.
                    if (!Enabled)
                        IsTouching = false;
                }
            }
            else
            {
                if (touching == false)
                {
                    //Report the separation to both participants:
                    if (FixtureA != null && FixtureA.OnSeparation != null)
                        FixtureA.OnSeparation(FixtureA, FixtureB);

                    //Reverse the order of the reported fixtures. The first fixture is always the one that the
                    //user subscribed to.
                    if (FixtureB != null && FixtureB.OnSeparation != null)
                        FixtureB.OnSeparation(FixtureB, FixtureA);

                    if (contactManager.EndContact != null)
                        contactManager.EndContact(this);
                }
            }

            if (sensor)
                return;

            if (contactManager.PreSolve != null)
                contactManager.PreSolve(this, ref oldManifold);
        }
Пример #46
0
        private async Task InitializeContactStoresAsync()
        {
            ContactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);

            ContactAnnotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);
        }
Пример #47
0
 public void OnAddCustomGroup(ContactManager _source, AsynchronousOperation _asyncOperation)
 {
 }
Пример #48
0
        /// <summary>
        /// Update the contact manifold and touching status.
        /// Note: do not assume the fixture AABBs are overlapping or are valid.
        /// </summary>
        /// <param name="contactManager">The contact manager.</param>
        internal void Update(ContactManager contactManager)
        {
            var bodyA = FixtureA.Body;
            var bodyB = FixtureB.Body;

            if (FixtureA == null || FixtureB == null)
            {
                return;
            }

            var oldManifold = Manifold;

            // Re-enable this contact.
            Enabled = true;

            bool touching;
            var  wasTouching = IsTouching;
            var  sensor      = FixtureA.IsSensor || FixtureB.IsSensor;

            // Is this contact a sensor?
            if (sensor)
            {
                var shapeA = FixtureA.Shape;
                var shapeB = FixtureB.Shape;
                touching = Collision.Collision.TestOverlap(shapeA, ChildIndexA, shapeB, ChildIndexB, ref bodyA._xf, ref bodyB._xf);

                // Sensors don't generate manifolds.
                Manifold.PointCount = 0;
            }
            else
            {
                Evaluate(ref Manifold, ref bodyA._xf, ref bodyB._xf);
                touching = Manifold.PointCount > 0;

                // Match old contact ids to new contact ids and copy the
                // stored impulses to warm start the solver.
                for (int i = 0; i < Manifold.PointCount; ++i)
                {
                    var mp2 = Manifold.Points[i];
                    mp2.NormalImpulse  = 0.0f;
                    mp2.TangentImpulse = 0.0f;
                    var id2 = mp2.Id;

                    for (int j = 0; j < oldManifold.PointCount; ++j)
                    {
                        var mp1 = oldManifold.Points[j];

                        if (mp1.Id.Key == id2.Key)
                        {
                            mp2.NormalImpulse  = mp1.NormalImpulse;
                            mp2.TangentImpulse = mp1.TangentImpulse;
                            break;
                        }
                    }

                    Manifold.Points[i] = mp2;
                }

                if (touching != wasTouching)
                {
                    bodyA.IsAwake = true;
                    bodyB.IsAwake = true;
                }
            }

            IsTouching = touching;
            if (wasTouching == false)
            {
                if (touching)
                {
                    if (Settings.AllCollisionCallbacksAgree)
                    {
                        bool enabledA = true, enabledB = true;

                        // Report the collision to both participants. Track which ones returned true so we can
                        // later call OnSeparation if the contact is disabled for a different reason.
                        if (FixtureA.OnCollision != null)
                        {
                            foreach (OnCollisionEventHandler handler in FixtureA.OnCollision.GetInvocationList())
                            {
                                enabledA = handler(FixtureA, FixtureB, this) && enabledA;
                            }
                        }

                        // Reverse the order of the reported fixtures. The first fixture is always the one that the
                        // user subscribed to.
                        if (FixtureB.OnCollision != null)
                        {
                            foreach (OnCollisionEventHandler handler in FixtureB.OnCollision.GetInvocationList())
                            {
                                enabledB = handler(FixtureB, FixtureA, this) && enabledB;
                            }
                        }

                        Enabled = enabledA && enabledB;

                        // BeginContact can also return false and disable the contact
                        if (enabledA && enabledB && contactManager.OnBeginContact != null)
                        {
                            Enabled = contactManager.OnBeginContact(this);
                        }
                    }
                    else
                    {
                        // Report the collision to both participants:
                        if (FixtureA.OnCollision != null)
                        {
                            foreach (OnCollisionEventHandler handler in FixtureA.OnCollision.GetInvocationList())
                            {
                                Enabled = handler(FixtureA, FixtureB, this);
                            }
                        }

                        //Reverse the order of the reported fixtures. The first fixture is always the one that the
                        //user subscribed to.
                        if (FixtureB.OnCollision != null)
                        {
                            foreach (OnCollisionEventHandler handler in FixtureB.OnCollision.GetInvocationList())
                            {
                                Enabled = handler(FixtureB, FixtureA, this);
                            }
                        }

                        //BeginContact can also return false and disable the contact
                        if (contactManager.OnBeginContact != null)
                        {
                            Enabled = contactManager.OnBeginContact(this);
                        }
                    }

                    // If the user disabled the contact (needed to exclude it in TOI solver) at any point by
                    // any of the callbacks, we need to mark it as not touching and call any separation
                    // callbacks for fixtures that didn't explicitly disable the collision.
                    if (!Enabled)
                    {
                        IsTouching = false;
                    }
                }
            }
            else
            {
                if (touching == false)
                {
                    // Report the separation to both participants:
                    if (FixtureA != null && FixtureA.OnSeparation != null)
                    {
                        FixtureA.OnSeparation(FixtureA, FixtureB);
                    }

                    //Reverse the order of the reported fixtures. The first fixture is always the one that the
                    //user subscribed to.
                    if (FixtureB != null && FixtureB.OnSeparation != null)
                    {
                        FixtureB.OnSeparation(FixtureB, FixtureA);
                    }

                    if (contactManager.OnEndContact != null)
                    {
                        contactManager.OnEndContact(this);
                    }
                }
            }

            if (sensor)
            {
                return;
            }

            if (contactManager.OnPreSolve != null)
            {
                contactManager.OnPreSolve(this, ref oldManifold);
            }
        }
Пример #49
0
 public UserInterface()
 {
     contactCreator = new ContactCreator();
     contactsDictionary = new ContactManager<long, string>();
 }
Пример #50
0
        private async Task <bool> CheckContactsAsync()
        {
            var accessStatus = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);

            return(accessStatus != null);
        }
Пример #51
0
 public ActionResult Index(SubscribeModel subscribe)
 {
     if (ModelState.IsValid)
     {
         using (new SecurityDisabler())
         {
             try
             {
                 string            emailAddress      = subscribe.Email;
                 EmailHelper       emailhelper       = new EmailHelper();
                 ContactRepository contactRepository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository;
                 var            contact        = contactRepository.LoadContactReadOnly(emailAddress);
                 ContactManager contactManager = Sitecore.Configuration.Factory.CreateObject("tracking/contactManager", true) as ContactManager;
                 LockAttemptResult <Contact> lockResult;
                 if (contact == null)
                 {
                     lockResult = new LockAttemptResult <Contact>(LockAttemptStatus.NotFound, null, null);
                     contact    = contactRepository.CreateContact(Sitecore.Data.ID.NewID);
                     contact.Identifiers.AuthenticationLevel = Sitecore.Analytics.Model.AuthenticationLevel.None;
                     contact.Identifiers.Identifier          = emailAddress;
                     contact.Identifiers.IdentificationLevel = ContactIdentificationLevel.Known;
                     contact.System.Value      = 0;
                     contact.System.VisitCount = 0;
                     contact.ContactSaveMode   = ContactSaveMode.AlwaysSave;
                     contactManager.FlushContactToXdb(contact);
                 }
                 else
                 {
                     lockResult = contactManager.TryLoadContact(contact.ContactId);
                     contact    = lockResult.Object;
                 }
                 var personal = contact.GetFacet <Sitecore.Analytics.Model.Entities.IContactPersonalInfo>("Personal");
                 personal.FirstName = subscribe.FullName;
                 var emailAddresses = contact.GetFacet <Sitecore.Analytics.Model.Entities.IContactEmailAddresses>("Emails");
                 if (!emailAddresses.Entries.Contains("Email"))
                 {
                     emailAddresses.Entries.Create("Email");
                 }
                 var email = emailAddresses.Entries["Email"];
                 email.SmtpAddress        = emailAddress;
                 emailAddresses.Preferred = "Email";
                 var contactEmailAddresses = contact.GetFacet <IVisitorSubscribtionFacet>("Contact Details");
                 if (!contactEmailAddresses.SubscriptionDetails.Contains("Subscriber Details"))
                 {
                     contactEmailAddresses.SubscriptionDetails.Create("Subscriber");
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].FullName      = subscribe.FullName;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].ContactNumber = subscribe.ContactNumber;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].Email         = subscribe.Email;
                     contactEmailAddresses.SubscriptionDetails["Subscriber"].Comments      = subscribe.Comments;
                 }
                 ContactListManager listManager = Sitecore.Configuration.Factory.CreateObject("contactListManager", false) as ContactListManager;
                 contactManager.SaveAndReleaseContactToXdb(contact);
                 Tracker.Current.Session.Identify(subscribe.Email);
                 //Getting the Email Campaign ManagerRoot
                 Item        managerRoot = Sitecore.Data.Database.GetDatabase(SitecoreHelper.GetSitecoreDB().ToString()).GetItem(GlobalProperties.EmailCampaignMangerRoot);
                 RecipientId recipient   = RecipientRepository.GetDefaultInstance().ResolveRecipientId("xdb:" + contact.ContactId);
                 var         recipientId = new Sitecore.Modules.EmailCampaign.Xdb.XdbContactId(contact.ContactId);
                 Sitecore.Modules.EmailCampaign.ClientApi.UpdateSubscriptions(recipientId, new[] { GlobalGuids.ContactList }, new string[] { }, managerRoot.ID.ToString(), false);
                 emailhelper.SendEmail(subscribe);
                 subscribe.IsFormEnabled = false;
             }
             catch (Exception ex)
             {
                 subscribe.IsError       = true;
                 subscribe.IsFormEnabled = false;
                 Sitecore.Diagnostics.Log.Error(ex.Message, this);
             }
         }
         return(View("~/Views/Pages/Subscribe.cshtml", subscribe));
     }
     subscribe.IsError       = false;
     subscribe.IsFormEnabled = true;
     return(View("~/Views/Pages/Subscribe.cshtml", subscribe));
 }
Пример #52
0
 /// <summary>
 /// Constructeur d'un <see cref="ConsoleUi"/>.
 /// </summary>
 public ConsoleUi()
 {
     _contactManager    = new ContactManager();
     _passwordTries     = 0;
     _serializationType = DEFAULT_SERIALIZATION_TYPE;
 }
Пример #53
0
 // Use this for initialization
 void Awake()
 {
     Instance = this;
 }
Пример #54
0
 public ContactManagerService(BaseFactory sitecoreFactory)
 {
     this.contactManager = sitecoreFactory.CreateObject("tracking/contactManager", true) as ContactManager;
 }
Пример #55
0
 /// <summary>
 /// 获取lync客户端
 /// </summary>
 void GetLyncClient()
 {
     while (_Client == null)
     {
         Thread.Sleep(iThreadSleepTime);
         try
         {
             _Client = LyncClient.GetClient();
             LyncContactManager = LyncClient.GetClient().ContactManager;
             LyncContactGroups = LyncClient.GetClient().ContactManager.Groups;                  
             _Client.StateChanged += new EventHandler<ClientStateChangedEventArgs>(LyncClientStateChanged);
             if (_Client.State == ClientState.SignedIn)//增加状态改变处理函数之前已经登录成功
             {
                 Thread.Sleep(iThreadSleepTime * 100);//等待1000毫秒,让lync状态改变时间触发
             }
         }
         catch
         {
             LogManager.SystemLog.Warn("LyncClient process is not running");
         }
     }
 }
Пример #56
0
		/// <summary>
		/// Update the contact manifold and touching status.
		/// Note: do not assume the fixture AABBs are overlapping or are valid.
		/// </summary>
		/// <param name="contactManager">The contact manager.</param>
		internal void update( ContactManager contactManager )
		{
			var bodyA = fixtureA.body;
			var bodyB = fixtureB.body;

			if( fixtureA == null || fixtureB == null )
				return;

			var oldManifold = manifold;

			// Re-enable this contact.
			enabled = true;

			bool touching;
			var wasTouching = isTouching;
			var sensor = fixtureA.isSensor || fixtureB.isSensor;

			// Is this contact a sensor?
			if( sensor )
			{
				var shapeA = fixtureA.shape;
				var shapeB = fixtureB.shape;
				touching = Collision.Collision.testOverlap( shapeA, childIndexA, shapeB, childIndexB, ref bodyA._xf, ref bodyB._xf );

				// Sensors don't generate manifolds.
				manifold.pointCount = 0;
			}
			else
			{
				evaluate( ref manifold, ref bodyA._xf, ref bodyB._xf );
				touching = manifold.pointCount > 0;

				// Match old contact ids to new contact ids and copy the
				// stored impulses to warm start the solver.
				for( int i = 0; i < manifold.pointCount; ++i )
				{
					var mp2 = manifold.points[i];
					mp2.normalImpulse = 0.0f;
					mp2.tangentImpulse = 0.0f;
					var id2 = mp2.id;

					for( int j = 0; j < oldManifold.pointCount; ++j )
					{
						var mp1 = oldManifold.points[j];

						if( mp1.id.key == id2.key )
						{
							mp2.normalImpulse = mp1.normalImpulse;
							mp2.tangentImpulse = mp1.tangentImpulse;
							break;
						}
					}

					manifold.points[i] = mp2;
				}

				if( touching != wasTouching )
				{
					bodyA.isAwake = true;
					bodyB.isAwake = true;
				}
			}

			isTouching = touching;
			if( wasTouching == false )
			{
				if( touching )
				{
					if( Settings.allCollisionCallbacksAgree )
					{
						bool enabledA = true, enabledB = true;

						// Report the collision to both participants. Track which ones returned true so we can
						// later call OnSeparation if the contact is disabled for a different reason.
						if( fixtureA.onCollision != null )
							foreach( OnCollisionEventHandler handler in fixtureA.onCollision.GetInvocationList() )
								enabledA = handler( fixtureA, fixtureB, this ) && enabledA;

						// Reverse the order of the reported fixtures. The first fixture is always the one that the
						// user subscribed to.
						if( fixtureB.onCollision != null )
							foreach( OnCollisionEventHandler handler in fixtureB.onCollision.GetInvocationList() )
								enabledB = handler( fixtureB, fixtureA, this ) && enabledB;

						enabled = enabledA && enabledB;

						// BeginContact can also return false and disable the contact
						if( enabledA && enabledB && contactManager.onBeginContact != null )
							enabled = contactManager.onBeginContact( this );
					}
					else
					{
						// Report the collision to both participants:
						if( fixtureA.onCollision != null )
							foreach( OnCollisionEventHandler handler in fixtureA.onCollision.GetInvocationList() )
								enabled = handler( fixtureA, fixtureB, this );

						//Reverse the order of the reported fixtures. The first fixture is always the one that the
						//user subscribed to.
						if( fixtureB.onCollision != null )
							foreach( OnCollisionEventHandler handler in fixtureB.onCollision.GetInvocationList() )
								enabled = handler( fixtureB, fixtureA, this );

						//BeginContact can also return false and disable the contact
						if( contactManager.onBeginContact != null )
							enabled = contactManager.onBeginContact( this );
					}

					// If the user disabled the contact (needed to exclude it in TOI solver) at any point by
					// any of the callbacks, we need to mark it as not touching and call any separation
					// callbacks for fixtures that didn't explicitly disable the collision.
					if( !enabled )
						isTouching = false;
				}
			}
			else
			{
				if( touching == false )
				{
					// Report the separation to both participants:
					if( fixtureA != null && fixtureA.onSeparation != null )
						fixtureA.onSeparation( fixtureA, fixtureB );

					//Reverse the order of the reported fixtures. The first fixture is always the one that the
					//user subscribed to.
					if( fixtureB != null && fixtureB.onSeparation != null )
						fixtureB.onSeparation( fixtureB, fixtureA );

					if( contactManager.onEndContact != null )
						contactManager.onEndContact( this );
				}
			}

			if( sensor )
				return;

			if( contactManager.onPreSolve != null )
				contactManager.onPreSolve( this, ref oldManifold );
		}
Пример #57
0
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            if (SettingsHelper.IsAuthorized)
            {
                if (args is ShareTargetActivatedEventArgs share)
                {
                    var package   = new DataPackage();
                    var operation = share.ShareOperation.Data;
                    if (operation.Contains(StandardDataFormats.ApplicationLink))
                    {
                        package.SetApplicationLink(await operation.GetApplicationLinkAsync());
                    }
                    if (operation.Contains(StandardDataFormats.Bitmap))
                    {
                        package.SetBitmap(await operation.GetBitmapAsync());
                    }
                    //if (operation.Contains(StandardDataFormats.Html))
                    //{
                    //    package.SetHtmlFormat(await operation.GetHtmlFormatAsync());
                    //}
                    //if (operation.Contains(StandardDataFormats.Rtf))
                    //{
                    //    package.SetRtf(await operation.GetRtfAsync());
                    //}
                    if (operation.Contains(StandardDataFormats.StorageItems))
                    {
                        package.SetStorageItems(await operation.GetStorageItemsAsync());
                    }
                    if (operation.Contains(StandardDataFormats.Text))
                    {
                        package.SetText(await operation.GetTextAsync());
                    }
                    //if (operation.Contains(StandardDataFormats.Uri))
                    //{
                    //    package.SetUri(await operation.GetUriAsync());
                    //}
                    if (operation.Contains(StandardDataFormats.WebLink))
                    {
                        package.SetWebLink(await operation.GetWebLinkAsync());
                    }

                    ShareOperation = share.ShareOperation;
                    DataPackage    = package.GetView();

                    var options = new LauncherOptions();
                    options.TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName;

                    await Launcher.LaunchUriAsync(new Uri("tg://"), options);
                }
                else if (args is VoiceCommandActivatedEventArgs voice)
                {
                    Execute.Initialize();

                    SpeechRecognitionResult speechResult = voice.Result;
                    string command = speechResult.RulePath[0];

                    if (command == "ShowAllDialogs")
                    {
                        NavigationService.NavigateToMain(null);
                    }
                    if (command == "ShowSpecificDialog")
                    {
                        //#TODO: Fix that this'll open a specific dialog
                        NavigationService.NavigateToMain(null);
                    }
                    else
                    {
                        NavigationService.NavigateToMain(null);
                    }
                }
                else if (args is ContactPanelActivatedEventArgs contact)
                {
                    var backgroundBrush = Application.Current.Resources["TelegramBackgroundTitlebarBrush"] as SolidColorBrush;
                    contact.ContactPanel.HeaderColor = backgroundBrush.Color;

                    var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

                    var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);

                    if (store != null && annotationStore != null)
                    {
                        var full = await store.GetContactAsync(contact.Contact.Id);

                        if (full == null)
                        {
                            NavigationService.NavigateToMain(null);
                        }
                        else
                        {
                            var annotations = await annotationStore.FindAnnotationsForContactAsync(full);

                            var first = annotations.FirstOrDefault();
                            if (first == null)
                            {
                                NavigationService.NavigateToMain(null);
                            }
                            else
                            {
                                var remote = first.RemoteId;
                                if (int.TryParse(remote.Substring(1), out int userId))
                                {
                                    NavigationService.Navigate(typeof(DialogPage), new TLPeerUser {
                                        UserId = userId
                                    });
                                }
                                else
                                {
                                    NavigationService.NavigateToMain(null);
                                }
                            }
                        }
                    }
                    else
                    {
                        NavigationService.NavigateToMain(null);
                    }
                }
                else if (args is ProtocolActivatedEventArgs protocol)
                {
                    Execute.Initialize();

                    if (ShareOperation != null)
                    {
                        ShareOperation.ReportCompleted();
                        ShareOperation = null;
                    }

                    if (NavigationService?.Frame?.Content is MainPage page)
                    {
                        page.Activate(protocol.Uri);
                    }
                    else
                    {
                        NavigationService.NavigateToMain(protocol.Uri.ToString());
                    }
                }
                else
                {
                    Execute.Initialize();

                    var activate = args as ToastNotificationActivatedEventArgs;
                    var launched = args as LaunchActivatedEventArgs;
                    var launch   = activate?.Argument ?? launched?.Arguments;

                    if (NavigationService?.Frame?.Content is MainPage page)
                    {
                        page.Activate(launch);
                    }
                    else
                    {
                        NavigationService.NavigateToMain(launch);
                    }
                }
            }
            else
            {
                Execute.Initialize();

                NavigationService.Navigate(typeof(IntroPage));
            }

            Window.Current.Activated         -= Window_Activated;
            Window.Current.Activated         += Window_Activated;
            Window.Current.VisibilityChanged -= Window_VisibilityChanged;
            Window.Current.VisibilityChanged += Window_VisibilityChanged;
            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated;
            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;

            UpdateBars();
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 500));
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

            Theme.Current.Update();
            NotifyThemeChanged();

            Task.Run(() => OnStartSync());
            //return Task.CompletedTask;
        }