public Dictionary<string, string> CheckPostcode(string postcode)
 {
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     if (!string.IsNullOrEmpty(postcode))
     {
         GoogleMapsMarker marker = this._storelocatorrepository.GetMarkerForPostcode(postcode, "")[0];
         if (marker != null)
         {
             this._locationLat = marker.lat.ToString();
             dictionary.Add("lat", this._locationLat);
             this._locationLong = marker.lng.ToString();
             dictionary.Add("long", this._locationLong);
         }
     }
     return dictionary;
 }
        /// <summary>
        /// Gets the relevant terms.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>
        /// IDictionary of types of tokens and values
        /// </returns>
        IDictionary<string, IEnumerable<string>> INlpProvider.GetRelevantTerms(string text)
        {
            IDictionary<string, IEnumerable<string>> returnDictionary = new Dictionary<string, IEnumerable<string>>();
            var annotation = new Annotation(text);
            NlpProvider.pipeline.annotate(annotation);

            var sentences = annotation.get(new CoreAnnotations.SentencesAnnotation().getClass()) as ArrayList;
            foreach (CoreMap sentence in sentences)
            {
                var tokens = sentence.get(new CoreAnnotations.TokensAnnotation().getClass()) as ArrayList;
                foreach (CoreLabel token in tokens)
                {
                    string pos = token.get(new CoreAnnotations.PartOfSpeechAnnotation().getClass()).ToString().ToUpper();
                    if (NlpProvider.relevantPos.Contains(pos))
                    {
                        List<string> listOfValues;
                        if (returnDictionary.ContainsKey(pos))
                        {
                            listOfValues = returnDictionary[pos] as List<string>;
                        }
                        else
                        {
                            listOfValues = new List<string>();
                            returnDictionary.Add(pos, listOfValues);
                        }

                        string word = token.get(new CoreAnnotations.TextAnnotation().getClass()).ToString();
                        listOfValues.Add(word);
                        ////var ner = token.get(new CoreAnnotations.NamedEntityTagAnnotation().getClass());
                        ////var normalizedner = token.get(new CoreAnnotations.NormalizedNamedEntityTagAnnotation().getClass());
                    }
                }
            }

            return returnDictionary;
        }
 public ActionResult Index(ComponentPresentation componentPresentation, UserProfile model)
 {
     this.Logger.DebugFormat("Called Update Profile >>>> ", new object[0]);
     try
     {
         ((dynamic) base.ViewBag).Title = componentPresentation.Component.Fields["title"].Value;
     }
     catch (Exception)
     {
     }
     string email = string.Empty;
     if (base.User.Identity.IsAuthenticated)
     {
         email = base.User.Identity.Name;
     }
     bool flag = this.IsEditModelValid(model);
     if (flag)
     {
         try
         {
             MembershipUser user = Membership.GetUser();
             if (user == null)
             {
                 flag = false;
                 this.Logger.DebugFormat("Update Profile mUser null", new object[0]);
             }
             if (model.AddressDetails.Postcode != null)
             {
                 this.FindPostcode(model);
             }
             if (model.RegistrationStatus == "postcode invalid")
             {
                 flag = false;
             }
             if (flag)
             {
                 this.Logger.DebugFormat("User profile start  >>>>", new object[0]);
                 CoatsUserProfile userProfile = CoatsUserProfile.GetProfile(user.Email);
                 if (userProfile != null)
                 {
                     string selectedKeywords = base.Request["CraftType"];
                     string str3 = base.Request["email-newsletter"];
                     string str4 = base.Request["visibile-profile"];
                     PublicasterServiceRequest request = new PublicasterServiceRequest();
                     string newsletter = "No";
                     if (str3.Trim() == WebConfiguration.Current.EmailNewsletterYes.Trim())
                     {
                         newsletter = "yes";
                     }
                     if (((selectedKeywords != null) || (str3 != null)) || (str4 != null))
                     {
                         List<TridionTcmUri> keywordsSelectListItems = GetKeywordsSelectListItems(selectedKeywords);
                         List<TridionTcmUri> second = GetKeywordsSelectListItems(str3);
                         List<TridionTcmUri> list3 = GetKeywordsSelectListItems(str4);
                         IEnumerable<TridionTcmUri> enumerable = keywordsSelectListItems.Union<TridionTcmUri>(second).Union<TridionTcmUri>(list3);
                         Dictionary<string, string> dictionary = new Dictionary<string, string>();
                         foreach (TridionTcmUri uri in enumerable)
                         {
                             dictionary.Add(uri.TcmId, "tcm");
                         }
                         userProfile.Keywords = dictionary;
                         model.Keywords = dictionary;
                     }
                     if (!string.IsNullOrEmpty(model.NewPassword))
                     {
                         if (model.NewPassword == model.VerifyNewPassword)
                         {
                             if (!string.IsNullOrEmpty(model.CurrentPassword))
                             {
                                 CoatsUserProfile profile = CoatsUserProfile.GetProfile(email);
                                 if (model.CurrentPassword == profile.PASSWORD)
                                 {
                                     model.CustomerDetails.Password = model.NewPassword;
                                 }
                                 else
                                 {
                                     flag = false;
                                     base.ModelState.AddModelError("CurrentPasswordIncorrect", Helper.GetResource("CurrentPasswordIncorrect"));
                                 }
                             }
                             else
                             {
                                 flag = false;
                             }
                         }
                         else
                         {
                             flag = false;
                             base.ModelState.AddModelError("NewPasswordsNotMatch", Helper.GetResource("NewPasswordsNotMatch"));
                         }
                     }
                     if (flag)
                     {
                         this.MapUserProfileForUpdate(model, userProfile);
                         userProfile.Save();
                         if ((str3 != null) && WebConfiguration.Current.CheckEmailNewsletterOption)
                         {
                             if (str3.Trim() == WebConfiguration.Current.EmailNewsletterYes.Trim())
                             {
                                 EmailUtility utility = new EmailUtility();
                                 string fromEmailAddress = ConfigurationManager.AppSettings["PasswordReminderEmailFrom"];
                                 string emailTemplate = ConfigurationManager.AppSettings["RegisterConfirmationEmailTemplate"];
                                 string registerThankYou = this._settings.RegisterThankYou;
                                 string str9 = HttpUtility.UrlEncode(General.Encrypt(userProfile.MAIL.Trim()));
                                 registerThankYou = registerThankYou + "?UserEmail=" + str9;
                                 model.CustomerDetails.SiteUrl = registerThankYou;
                                 model.CustomerDetails.DisplayName = userProfile.DISPLAYNAME;
                                 model.CustomerDetails.EmailAddress = userProfile.MAIL;
                                 string str10 = utility.SendEmail(model.CustomerDetails, emailTemplate, fromEmailAddress, userProfile.MAIL);
                                 this.Logger.DebugFormat("ProfileController : Register Confirmation Email > result {0}", new object[] { str10 });
                                 request.createJsonPublicasterRequest(userProfile.MAIL, userProfile.NAME, userProfile.SURNAME, selectedKeywords, userProfile.DISPLAYNAME, newsletter);
                             }
                             else
                             {
                                 request.UnSubscripePublicaster(userProfile.MAIL);
                             }
                         }
                         CoatsUserProfile profile3 = CoatsUserProfile.GetProfile(userProfile.MAIL);
                         CookieHelper.WriteFormsCookie(userProfile.MAIL, userProfile.DISPLAYNAME, userProfile.NAME, userProfile.SURNAME, userProfile.LONG, userProfile.LAT, "");
                         ((dynamic) base.ViewBag).profileStatus = "saved";
                         if (profile3 == null)
                         {
                             flag = false;
                             base.ModelState.AddModelError(string.Empty, "");
                             this.Logger.DebugFormat("Update Profile newUser null", new object[0]);
                         }
                     }
                 }
             }
         }
         catch (Exception exception)
         {
             this.Logger.DebugFormat("Update Profile exception {0} {1}", new object[] { exception.Message, exception.InnerException });
             flag = false;
         }
     }
     if (base.ModelState.ContainsKey("CustomerDetails.DisplayName"))
     {
         base.ModelState["CustomerDetails.DisplayName"].Errors.Clear();
     }
     if (base.ModelState.ContainsKey("CustomerDetails.EmailAddress"))
     {
         base.ModelState["CustomerDetails.EmailAddress"].Errors.Clear();
     }
     if (!flag)
     {
         UserProfile profile4 = this.GetModel();
         base.ModelState.AddModelError(string.Empty, "");
         var typeArray = (from x in base.ModelState
             where x.Value.Errors.Count > 0
             select new { 
                 Key = x.Key,
                 Errors = x.Value.Errors
             }).ToArray();
         foreach (var type in typeArray)
         {
             this.Logger.DebugFormat("Update Profile error {0}", new object[] { type });
         }
         this.GetModelData(profile4);
         base.Session["feedback"] = Helper.GetResource("ProfileError");
         ((dynamic) base.ViewBag).profileStatus = "error";
         return base.View(profile4);
     }
     UserProfile profile5 = this.GetModel();
     base.Session["feedback"] = Helper.GetResource("ProfileChangesSaved");
     return base.View(profile5);
 }
        /// <summary>
        /// Loads the instrument list from the instruments.txt file
        /// </summary>
        /// <returns></returns>
        private void LoadInstruments()
        {
            if (!File.Exists(InstrumentsFileName))
                throw new FileNotFoundException(InstrumentsFileName + " file not found.");

            _instruments = new Dictionary<string, LeanInstrument>();

            var lines = File.ReadAllLines(InstrumentsFileName);
            foreach (var line in lines)
            {
                var tokens = line.Split(',');
                if (tokens.Length >= 3)
                {
                    var fxcmSymbol = tokens[0];
                    var securityType = (SecurityType)Enum.Parse(typeof(SecurityType), tokens[2]);
                    var symbol = ConvertFxcmSymbolToLeanSymbol(fxcmSymbol, securityType);
                    _instruments.Add(symbol.Value, new LeanInstrument
                    {
                        Symbol = symbol.Value,
                        Name = tokens[1],
                        Type = securityType
                    });

                    _mapInstrumentSymbols[symbol] = fxcmSymbol;
                }
            }
        }
Example #5
0
        public bool GenerateForAllUsedIncomplete()
        {
            var allAssemblyTypes = new Dictionary<string, Type>();

            foreach (Type t in TargetAssembly.GetTypes().Where(t => t.IsPublic))
            {
                if (!allAssemblyTypes.ContainsKey(t.Name))
                    allAssemblyTypes.Add(t.Name, t);
            }

            bool added = false;

            foreach (Type type in UsedTypes.ToArray())
            {
                if (!TypeIsWrapped(type))
                    throw new InvalidOperationException();

                if (!CompleteTypes.ContainsKey(type))
                {
                    var wci = new WrapperClassInfo(type, this);
                    CompleteTypes.Add(type, wci);

                    foreach (
                        Type inheritedType in
                            allAssemblyTypes.Values.Where(t => t.IsSubclassOf(wci.WrappedType) && t.IsPublic)
                                .Where(TypeIsWrapped))
                    {
                        if (inheritedType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Count() == 0
                            && !UsedTypes.Contains(inheritedType))
                            UsedTypes.Add(inheritedType);
                    }

                    var sb = new StringBuilder();

                    if (wci.IsInterface)
                        wci.GenerateInterfaceCode(sb);
                    else
                        wci.GenerateClassCode(sb);

                    if (wci.FilePathBase.IndexOfAny(new[] { '\\', '/' }) != -1)
                        Directory.CreateDirectory(Path.GetDirectoryName(wci.FilePathBase));

                    WriteTextToFile(wci.FilePathBase + ".cs", sb.ToString(), true);

                    wci.GenerateUserClassFile();

                    added = true;
                }
            }

            return added;
        }