コード例 #1
0
ファイル: User.cs プロジェクト: liamning/WebPortal
    public void commitSuggestion(SuggestionInfo info)
    {
        getReceiverMailAndName();

        //transfer the line-break to html line-break
        info.Suggestion = info.Suggestion.Replace("\n", "<br>");
        //create database access object
        string sql = " INSERT INTO [Suggestion] "
                     + "([UserName] ,[Email] ,[Type] ,[PhoneNumber] ,[OtherEmail],[Suggestion],[CreateBy],[CreateDate]) "
                     + " VALUES (@UserName, @Email, @Type, @PhoneNumber, @OtherEmail, @Suggestion, @CreateBy, getDate()) ";
        Dictionary <string, object> dict = new Dictionary <string, object>();

        dbAccess.open();
        try
        {
            dict.Add("@UserName", info.UserName);
            dict.Add("@Email", info.Email);
            dict.Add("@Type", info.Type);
            dict.Add("@PhoneNumber", info.PhoneNumber);
            dict.Add("@OtherEmail", info.OtherEmail);
            dict.Add("@Suggestion", info.Suggestion);
            dict.Add("@CreateBy", info.CreateBy);

            dbAccess.update(sql, dict);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            dbAccess.close();
        }
        sendMail(info);
    }
コード例 #2
0
ファイル: User.cs プロジェクト: liamning/WebPortal
    public void sendMail(SuggestionInfo info)
    {
        MailAddress  fromAddress = new MailAddress(SystemMailAccount, SystemMailDisplayName);
        MailAddress  toAddress   = new MailAddress(SupervisorMailAccount, SupervisorMailDisplayName);
        const string subject     = "Blue Cross Web Portal Suggestion";
        string       body        = "Dear " + SupervisorMailDisplayName + ", <br/><br/>Please find the suggestion below:<br/><br/>";

        body += info.Suggestion + "<br/><br/>";
        // body += "Submitted by " + info.UserName + "<br/>";
        // body += "Email : " + info.Email + "<br/>";
        //body += "Tel. : " + (string.IsNullOrEmpty(info.PhoneNumber) ? "N/A" : info.PhoneNumber) + "<span style='padding-left:50px;'>Other Email : </span>" + (string.IsNullOrEmpty(info.OtherEmail) ? "N/A" : info.OtherEmail) + "<br/>";


        //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        SmtpClient smtp = new SmtpClient(SMTPServer, SMTPPortNo);

        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
        smtp.UseDefaultCredentials = false;
        //smtp.Credentials = new NetworkCredential(fromAddress.Address, SystemMailPassword);
        smtp.Credentials = new NetworkCredential(fromAddress.Address, "");
        //smtp.Credentials = System.Net.CredentialCache.DefaultCredentials;
        //smtp.EnableSsl = true;


        MailMessage message = new MailMessage(fromAddress, toAddress);

        message.Subject    = subject;
        message.Body       = body;
        message.IsBodyHtml = true;

        using (message)
        {
            smtp.Send(message);
        }
    }
コード例 #3
0
        //Reune todas las funciones anteriores y crea la sugerencias armadas
        public async Task <IList <SuggestionInfo> > CreateSuggestedRelation(IList <User> users)
        {
            List <User> myList = await searchUserToSuggest(users);

            if (myList.Count == 0)
            {
                //Error
                System.Console.WriteLine("Vacio");
            }
            else
            {
                foreach (var item in myList)
                {
                    Suggestion aux = new Suggestion
                    {
                        Id       = System.Guid.NewGuid().ToString(),
                        IsActive = true
                    };
                    SuggestionInfo metaData = new SuggestionInfo
                    {
                        Suggestion    = aux,
                        SuggestedUser = item
                    };
                    addSuggestion(aux);
                    addMetadata(metaData);
                }
                await CreateSuggestion(Suggestions);
                await CreateRelationshipSuggestion(SuggestionInfos);
            }
            return(SuggestionInfos);
        }
コード例 #4
0
        //Consultada sugerencias de un usuario
        public async Task <List <SuggestionInfo> > getSuggestion(IList <User> users)
        {
            string cypher = new StringBuilder()
                            .AppendLine("UNWIND $users AS user")
                            //Identifica usuario
                            .AppendLine("MATCH (myuser:User {id: user.id})")
                            //Traer sugerencias que tiene el usuario
                            .AppendLine("MATCH ((myuser)-[:GET]-(s:Suggestion)-[:SUGGEST]-(u:User))")
                            //Filtrar que no esten desactivados
                            .AppendLine("WHERE NOT(s.isActive = false)")
                            .AppendLine("RETURN u.id, u.name, s.id, s.isActive")
                            .ToString();
            var session = client.GetDriver().AsyncSession(o => o.WithDatabase("neo4j"));
            List <SuggestionInfo> mySuggInfoList = new List <SuggestionInfo>();

            try
            {
                var reader = await session.RunAsync(cypher, new Dictionary <string, object>() { { "users", ParameterSerializer.ToDictionary(users) } });

                while (await reader.FetchAsync())
                {
                    int      count = 0;
                    string[] aux   = new string[3];
                    foreach (var item in reader.Current.Values)
                    {
                        if (count == 3)
                        {
                            User myuser = new User {
                                Id   = aux[0],
                                Name = aux[1]
                            };
                            Suggestion mySugg = new Suggestion {
                                Id       = aux[2],
                                IsActive = (bool)item.Value
                            };
                            SuggestionInfo SuggInfo = new SuggestionInfo
                            {
                                Suggestion    = mySugg,
                                SuggestedUser = myuser
                            };
                            mySuggInfoList.Add(SuggInfo);
                        }
                        else
                        {
                            aux[count] = item.Value.ToString();
                        }
                        count++;
                    }
                }
            }
            finally { await session.CloseAsync(); }
            return(mySuggInfoList);
        }
コード例 #5
0
 private static void PrintSuggestion(SuggestionInfo suggestion, int index, int count)
 {
     Console.WriteLine("[#{0}/{1}] {2} ({3}) | Current: {4} ({5}) | Suggested: {6}",
                       index, count,
                       suggestion.App.SteamName, suggestion.App.SteamAppId,
                       suggestion.OriginalHltbName, suggestion.OriginalHltbId,
                       suggestion.Suggestion.AppType == AppEntity.NonGameTypeName
             ? "[non-finite game/app]"
             : (String.Format(CultureInfo.InvariantCulture, "{0} ({1})", suggestion.App.HltbName, suggestion.App.HltbId)) +
                       (suggestion.Suggestion.IsRetype
                   ? String.Format(CultureInfo.InvariantCulture, " [{0}]", suggestion.Suggestion.AppType)
                   : String.Empty));
 }
コード例 #6
0
        private static void InspectSuggestion(SuggestionInfo suggestion)
        {
            Console.WriteLine("Launching Steam game page...");
            Process.Start(String.Format(CultureInfo.InvariantCulture, SteamStoreGamePageTemplate, suggestion.App.SteamAppId));

            if (suggestion.App.HltbId >= 0)
            {
                Console.WriteLine("Launching suggested HLTB game page...");
                Process.Start(String.Format(CultureInfo.InvariantCulture, HltbScraper.HltbGamePageFormat, suggestion.App.HltbId));
            }
            else if (suggestion.Suggestion.IsRetype && suggestion.OriginalHltbId >= 0)
            {
                Console.WriteLine("Launching HLTB game page...");
                Process.Start(String.Format(CultureInfo.InvariantCulture, HltbScraper.HltbGamePageFormat, suggestion.OriginalHltbId));
            }
        }
コード例 #7
0
 public void addMetadata(SuggestionInfo suggestionInfo)
 {
     this.mySuggestionInfo.Add(suggestionInfo);
 }