string TestEmail(Settings settings)
    {
        string email = settings.Email;
        string smtpServer = settings.SmtpServer;
        string smtpServerPort = settings.SmtpServerPort.ToString();
        string smtpUserName = settings.SmtpUserName;
        string smtpPassword = settings.SmtpPassword;
        string enableSsl = settings.EnableSsl.ToString();

        var mail = new MailMessage
        {
            From = new MailAddress(email, smtpUserName),
            Subject = string.Format("Test mail from {0}", smtpUserName),
            IsBodyHtml = true
        };
        mail.To.Add(mail.From);
        var body = new StringBuilder();
        body.Append("<div style=\"font: 11px verdana, arial\">");
        body.Append("Success");
        if (HttpContext.Current != null)
        {
            body.Append(
                "<br /><br />_______________________________________________________________________________<br /><br />");
            body.AppendFormat("<strong>IP address:</strong> {0}<br />", Utils.GetClientIP());
            body.AppendFormat("<strong>User-agent:</strong> {0}", HttpContext.Current.Request.UserAgent);
        }

        body.Append("</div>");
        mail.Body = body.ToString();

        return Utils.SendMailMessage(mail, smtpServer, smtpServerPort, smtpUserName, smtpPassword, enableSsl.ToString());
    }
Example #2
0
    public override string ToString()
    {
        var arguments = new StringBuilder();

        arguments.AppendFormat("\"{0}\"", workingDirectory);

        if (!string.IsNullOrWhiteSpace(exec))
        {
            arguments.AppendFormat(" /exec \"{0}\"", exec);
        }

        if (!string.IsNullOrWhiteSpace(execArgs))
        {
            arguments.AppendFormat(" /execArgs \"{0}\"", execArgs);
        }

        if (!string.IsNullOrWhiteSpace(projectFile))
        {
            arguments.AppendFormat(" /proj \"{0}\"", projectFile);
        }

        if (!string.IsNullOrWhiteSpace(projectArgs))
        {
            arguments.AppendFormat(" /projargs \"{0}\"", projectArgs);
        }

        arguments.Append(additionalArguments);

        if (!string.IsNullOrWhiteSpace(logFile))
        {
            arguments.AppendFormat(" /l \"{0}\"", logFile);
        }

        return arguments.ToString();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CustomTableItem != null)
        {
            DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(CustomTableItem.CustomTableClassName);
            if (dci != null)
            {
                // Get class form definition
                FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);

                string fieldCaption;
                FormFieldInfo ffi;
                IDataContainer item = CustomTableItem;

                StringBuilder sb = new StringBuilder();
                sb.Append("<table class=\"table table-hover\">");
                // Table header
                sb.AppendFormat("<thead><tr class=\"unigrid-head\"><th>{0}</th><th class=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("customtable.data.nametitle"), GetString("customtable.data.namevalue"));

                // Get macro resolver
                MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);

                // Go through the columns
                foreach (string columnName in item.ColumnNames)
                {
                    // Get field caption
                    ffi = fi.GetFormField(columnName);
                    if (ffi == null)
                    {
                        fieldCaption = columnName;
                    }
                    else
                    {
                        string caption = ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, resolver);
                        if (string.IsNullOrEmpty(caption))
                        {
                            fieldCaption = columnName;
                        }
                        else
                        {
                            fieldCaption = ResHelper.LocalizeString(caption);
                        }
                    }

                    sb.AppendFormat("<tr><td><strong>{0}</strong></td><td class=\"wrap-normal\">{1}</td></tr>", fieldCaption, HTMLHelper.HTMLEncode(ValidationHelper.GetString(item.GetValue(columnName), String.Empty)));
                }
                sb.Append("</tbody></table>");

                ltlContent.Text = sb.ToString();
            }
            else
            {
                ltlContent.Text = GetString("editedobject.notexists");
            }
        }
        else
        {
            ltlContent.Text = GetString("editedobject.notexists");
        }
    }
Example #4
0
		public void ButtonChart_Click(object sender, System.EventArgs e)
		{
			//We first request the data from the form (Default.aspx)
			string soups, salads, sandwiches, beverages, desserts;
            soups = TextBoxSoups.Text;
			salads = TextboxSalads.Text;
			sandwiches = TextboxSandwiches.Text;
			beverages = TextboxBeverages.Text;
			desserts   = TextboxDesserts.Text;
	
			//In this example, we're directly showing this data back on chart.
			//In your apps, you can do the required processing and then show the 
			//relevant data only.
	
			//Now that we've the data in variables, we need to convert this into XML.
			//The simplest method to convert data into XML is using string concatenation.	
            StringBuilder xmlData = new StringBuilder();
			//Initialize <chart> element
			xmlData.Append("<chart caption='Sales by Product Category' subCaption='For this week' showPercentValues='1' pieSliceDepth='30' showBorder='1'>");
			//Add all data
			xmlData.AppendFormat("<set label='Soups' value='{0}' />",soups);
			xmlData.AppendFormat("<set label='Salads' value='{0}' />",salads);
			xmlData.AppendFormat("<set label='Sandwiches' value='{0}' />", sandwiches);
            xmlData.AppendFormat("<set label='Beverages' value='{0}' />", beverages);
			xmlData.AppendFormat("<set label='Desserts' value='{0}' />",desserts);
			//Close <chart> element
			xmlData.Append("</chart>");
                        
			//Create the chart - Pie 3D Chart with data from xmlData
            LiteralChart.Text = FusionCharts.RenderChart("../FusionCharts/Pie3D.swf", "", xmlData.ToString(), "Sales", "500", "300", false, false);
		}
Example #5
0
    private void BindGroups()
    {
        string sql = "select * from [group] where [g_tags] like '%" + tag + "%'";
        DataTable dt = DB.GetTable(sql);

        int cnt = dt != null ? dt.Rows.Count : 0;

        if (cnt == 0) return;

        pageCount = cnt / pageSize;
        if (cnt % pageSize > 0) pageCount++;
        pageIndex = Math.Max(0, pageIndex);
        pageIndex = Math.Min(pageCount - 1, pageIndex);

        StringBuilder sb = new StringBuilder();
        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div style='margin-top:16px;margin-left:14px;'>");
            sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", row["g_id"], Settings.Ext, Strings.GroupSmallImageError);
            sb.AppendFormat("<div class='iright'><a class='bold' href='/group/{0}{1}' target=_blank>{2}</a>", row["g_id"], Settings.Ext, Tools.HtmlEncode(row["g_name"].ToString()));
            sb.AppendFormat("<p>{0}</p>", Tools.HtmlEncode(row["g_description"].ToString()));
            sb.AppendFormat("<span class='em'>标签:{0}</span></div>", TagTools.ToLinks(row["g_tags"].ToString(), true));
            sb.Append("<div class='clear'></div></div>");
        }
        lblGroupList.Text = sb.ToString();

        if (pageCount > 1)
        {
            string url = String.Format("/group/tag/{0}/{1}{2}", tag, "{0}", Settings.Ext);
            lblPageList.Text = Tools.GetPager(pageIndex, pageCount, pageNumber, url);
        }
    }
Example #6
0
    private void BindData()
    {
        string fields = "[_name],[fullname],[state],[city],[jianjie]";
        string where = "[hangye]='" + tag + "'";
        string sql = "select {0} from [users] where {1} order by [_name]";
        sql = String.Format(sql, fields, where);

        DataTable dt = DB.GetTable(sql);

        StringBuilder sb = new StringBuilder();

        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div style='margin-top:16px;margin-left:14px;'>");
            sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", row["_name"], Settings.Ext, Strings.UserSmallImageError);
            sb.AppendFormat("<div class='iright'><a class='bold' href='/{0}{1}' target=_blank>{0}</a> ({2})", row["_name"], Settings.Ext, row["fullname"]);

            if (row["state"].ToString() != "")
            {
                if (row["state"].ToString().Substring(0, 2) == row["city"].ToString().Substring(0, 2))
                {
                    sb.AppendFormat(" <a href='/city/{0}{1}'>{0}</a>", row["city"], Settings.Ext);
                }
                else
                {
                    sb.AppendFormat(" <a href='/city/{0}{1}'>{0}</a>,<a href='/city/{2}{1}'>{2}</a>", row["state"], Settings.Ext, row["city"]);
                }
            }
            sb.AppendFormat("<p><span style='color:#888888;'>简介:</span>{0}</p>", Tools.HtmlEncode(Tools.CutString(row["jianjie"].ToString(), 126)));
            sb.Append("</div><div class='clear'></div></div>");
        }
        lblDataList.Text = sb.ToString();
    }
        private string GetCharArrayInfo(char[] chars, int startIndex, int count)
        {
            StringBuilder sb = new StringBuilder();

            if (null == chars) return string.Empty;
            if (0 == chars.Length)
            {
                sb.Append("\nThe character array is zero-length array: {}");
            }
            else
            {
                sb.Append("\nThe character array is: {");
                for (int i = 0; i < chars.Length; ++i)
                {
                    if (0 == (i & 0xf)) sb.Append("\n");
                    sb.AppendFormat("\t\\u{0:X04}, ", (int)chars[i]);
                }
                sb.Append("}");
            }
            sb.AppendFormat("\nThe length of character array: {0}", chars.Length);
            sb.AppendFormat("\nStart index for encoding: {0}\nCount of character encoded: {1}",
                            startIndex, count);

            return sb.ToString();
        }
Example #8
0
    private static HtmlString Include(string path)
    {
        if (HttpRuntime.Cache[path] == null)
        {
            var absolute = HostingEnvironment.MapPath(path) ?? "";
            var ext = Path.GetExtension(absolute);
            var fmt = ext == ".js"
                ? "<script type=\"text/javascript\" src=\"{0}\"></script>\n"
                : "<link href=\"{0}\" rel=\"stylesheet\" />\n";
            var result = new StringBuilder();
#if DEBUG
            result.AppendFormat(fmt, path);
#else
            const string min = ".min";
            var dt = File.GetLastWriteTime(absolute);
            var f = Path.GetFileNameWithoutExtension(absolute);
            var d = path.Remove(path.LastIndexOf('/'));
            var t = $"v-{dt:yyMMddhhmmss}-";
            var minfile = $"{d}/{f}{min}{ext}";
            var p = File.Exists(HostingEnvironment.MapPath(minfile))
                ? $"{d}/{t}{f}{min}{ext}"
                : $"{d}/{t}{f}{ext}";
            result.AppendFormat(fmt, p);
#endif
            HttpRuntime.Cache.Insert(path, result.ToString(), new CacheDependency(absolute));
        }
        return new HtmlString(HttpRuntime.Cache[path] as string);
    }
    void LogGestures(BaseGesture[] gestures, long frameKey)
    {
        StringBuilder logLine = new StringBuilder();
        logLine.AppendFormat("Gestures frame: {0}, contains {1} gestures\n", frameKey, gestures.Length);

        int gestureCounter = 0;

        foreach (BaseGesture gesture in gestures)
        {
            string additionalGestureData = "";
            // Update messages for gesture

            switch (gesture.Type)
            {
            case BaseGesture.GestureType.HEAD_POSITION:
            {
                HeadPositionGesture headPositionGesture = gesture as HeadPositionGesture;
                additionalGestureData = " (" + headPositionGesture.RegionIndex+")";
                break;
            }
            case BaseGesture.GestureType.WINGS:
            {
                WingsGesture wingsGesture = gesture as WingsGesture;
                additionalGestureData = " (" + wingsGesture.ArmsAngle + ")";
                break;
            }
            default:
                break;
            }
            logLine.AppendFormat("{0}. Gesture id: {1} -  {2}{3}\n",gestureCounter, gesture.ID , gesture.Description, additionalGestureData);
            gestureCounter++;
        }
        Debug.Log(logLine);
    }
Example #10
0
 static void PolynomMultiplication(int[] firstPol, int[] secondPol)
 {
     int[] multiPol = new int[firstPol.Length + secondPol.Length];
     int startPoint = 0;
     for (int i = 0; i < firstPol.Length; i++)
     {
         startPoint = i;
         for (int j = 0; j < secondPol.Length; j++)
         {
             multiPol[startPoint] = multiPol[startPoint] + (secondPol[j] * firstPol[i]);
             startPoint++;
         }
     }
     StringBuilder strMultiPol = new StringBuilder();
     if (multiPol[0] != 0)
     {
         strMultiPol.AppendFormat("{0} ", multiPol[0]);
     }
     for (int i = 1; i < multiPol.Length; i++)
     {
         if (multiPol[i] != 0 && multiPol[i] > 0)
         {
             strMultiPol.AppendFormat("+ {0}x^{1} ", multiPol[i], i);
         }
         if (multiPol[i] < 0)
         {
             strMultiPol.AppendFormat("{0}x^{1} ", multiPol[i], i);
         }
     }
     Console.WriteLine(strMultiPol.ToString());
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string likeElementForSearchingDB = string.Empty;

        if (Request.QueryString.Count == 3)
        {
            likeElementForSearchingDB = Request.QueryString[2];

        }

        PatientInfoDAL objPat_Info = new PatientInfoDAL();

        objPat_Info = new PatientInfoDAL();

        DataTable Doc_Names = objPat_Info.get_DoctorNames(likeElementForSearchingDB);

        var sb = new StringBuilder();
        for (int i = 0; i < Doc_Names.Rows.Count; i++)
        {
            switch (i)
            {
                case 0:
                    sb.AppendFormat(keyValueFormater, Doc_Names.Rows[i][2], string.Format("{1}, {0} - {2}", Doc_Names.Rows[i][1], Doc_Names.Rows[i][0], Doc_Names.Rows[i][3]), "{", "}");
                    break;
                default:
                    sb.AppendFormat(keyValueFormaterIntermediatElement, Doc_Names.Rows[i][2], string.Format("{1}, {0} - {2}", Doc_Names.Rows[i][1], Doc_Names.Rows[i][0], Doc_Names.Rows[i][3]), "{", "}");
                    break;
            }
        }
        Response.Write(string.Format(jasonPacketFormater, sb.ToString()));
    }
Example #12
0
    public string ConvertToMessage(AttributeData attributeData)
    {
        var stringBuilder = new StringBuilder();
        var message = attributeData.Message;
        if (message != null)
        {
            message = message.Trim();
            message = message.Trim('.');
            stringBuilder.AppendFormat("{0}. ", message);
        }

        if (attributeData.Replacement != null)
        {
            stringBuilder.AppendFormat(ReplacementFormat, attributeData.Replacement);
        }

        if (assemblyVersion < attributeData.TreatAsErrorFromVersion)
        {
            stringBuilder.AppendFormat(TreatAsErrorFormat, attributeData.TreatAsErrorFromVersion.ToSemVer());
        }
        if (attributeData.ThrowsNotImplemented)
        {
            stringBuilder.Append(ThrowsNotImplementedText);
        }
        stringBuilder.AppendFormat(RemoveInVersionFormat, attributeData.RemoveInVersion.ToSemVer());

        return stringBuilder.ToString().Trim();
    }
    /// <summary>
    /// 定数を管理するクラスを自動生成する
    /// </summary>
    /// <param name="className">クラスの名前</param>
    /// <param name="classInfo">なんのクラスか説明するコメント文</param>
    /// <param name="variableDic">定数名とその値をセットで登録したDictionary</param>
    /// <typeparam name="T">定数の型、stringかintかfloat</typeparam>
    public static void Create(string className, string classInfo, string[] value)
    {
        //コメント文とクラス名を入力
        StringBuilder builder = new StringBuilder();

        builder.AppendLine("/// <summary>");
        builder.AppendFormat("/// {0}", classInfo).AppendLine();
        builder.AppendLine("/// </summary>");
        builder.AppendFormat("namespace {0}", className).AppendLine("{");
        builder.Append("\t").AppendFormat("public enum SceneName").AppendLine("{");
        for (int i = 0; i < value.Length; i++)
        {
            builder.Append("\t\t").AppendFormat("{0},", value[i]).AppendLine("");
        }

        builder.Append("\t").AppendLine("}");
        builder.AppendLine("}");

        //書き出し、ファイル名はクラス名.cs
        string exportPath = "Assets/Scripts/Scripts/Constants/AutoCreating/" + className + ".cs";

        //書き出し先のディレクトリが無ければ作成
        string directoryName = Path.GetDirectoryName(exportPath);
        if (!Directory.Exists(directoryName))
        {
            Directory.CreateDirectory(directoryName);
        }

        File.WriteAllText(exportPath, builder.ToString(), Encoding.UTF8);
        AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);

        Debug.Log(className+"の作成が完了しました");
    }
Example #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var sb = new StringBuilder();
        sb.AppendFormat(@"<ul class=""tin-view-navi-menus spa-view-navi-menus"">");
        sb.AppendFormat(@"<li>
        <a href=""/"" class=""tin-view-navi-menus-item home"">
        Trang chủ
        </a>
        </li>");
        sb.Append(
            @"<li><a class=""tin-view-navi-menus-item"" href=""/Spa-khuyen-mai/"">Spa khuyến mãi</a></li>");
        sb.AppendFormat(@"</ul>");
        txtPath = sb.ToString();

        this.Page.Header.Title = string.Format(Item.Ten + " Spa khuyến mãi, Spa giảm giá, spa voucher - Tạp chí spa");

        var meta = new HtmlMeta();
        meta.Name = "description";
        meta.Content = Item.MoTa;
        this.Page.Header.Controls.Add(meta);

        meta = new HtmlMeta();
        meta.Name = "og:description";
        meta.Content = Item.MoTa;
        this.Page.Header.Controls.Add(meta);

        meta = new HtmlMeta();
        meta.Name = "og:title";
        meta.Content = string.Format(Item.Ten + " Spa khuyến mãi, Spa giảm giá, spa voucher - Tạp chí spa");
        this.Page.Header.Controls.Add(meta);
    }
Example #15
0
    protected void Application_Error(Object sender, EventArgs e)
    {

        StringBuilder message = new StringBuilder();

        // String e1 = Context.Error.ToString();

        if (Request != null)
        {
            message.AppendFormat(uriFormat, Request.Path);
        }

        if (Server != null)
        {

            Exception ex;
            for (ex = Server.GetLastError(); ex != null; ex = ex.InnerException)
            {

                message.AppendFormat(exceptionFormat,
                    ex.GetType().Name,
                    ex.Message,
                    ex.StackTrace);
            }
        }

        Session["TheException"] = message.ToString();


    }
Example #16
0
    private string GetUserDataText(IUserContext uc)
    {
        var sb = new StringBuilder();

        var data = uc.Data;
        sb.AppendLine("Data<size=28>");
        sb.AppendFormat("RegisterTime: {0}\n", data.RegisterTime);
        sb.AppendFormat("LastLoginTime: {0}\n", data.LastLoginTime);
        sb.AppendFormat("LoginCount: {0}\n", data.LoginCount);
        sb.AppendLine("</size>");

        var achivements = uc.Achivements;
        sb.AppendLine("Achievement<size=28>");
        foreach (AchievementKey key in Enum.GetValues(typeof(AchievementKey)))
        {
            UserAchievement ach;
            if (achivements.TryGetValue((int)key, out ach))
            {
                if (ach.AchieveTime.HasValue)
                    sb.AppendFormat("{0}: Achieved({1})\n", key, ach.AchieveTime.Value);
                else
                    sb.AppendFormat("{0}: Progress({1})\n", key, ach.Value);
            }
        }
        sb.AppendLine("</size>");

        return sb.ToString();
    }
    private void LoadBannerRight()
    {
        ltlRight.Text = string.Empty;
        StringBuilder sb = new StringBuilder();

        //搜尋條件
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "7");
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "9");
        conditions.Add("Order", string.Format("order by {0}", "p.SortNo, p.PostId"));

        IList<PostVO> list = m_PostService.GetPostList(conditions);
        if (list != null && list.Count > 0)
        {
            foreach (PostVO post in list)
            {
                if (string.IsNullOrEmpty(post.LinkUrl))
                {
                    sb.AppendFormat("<div style=\"background-image: url('upload/{0}')\" class=\"contant_right_ad\" ></div>", post.PicFileName);
                }
                else
                {
                    sb.AppendFormat("<div style=\"background-image: url('upload/{0}'); cursor: pointer;\" class='contant_right_ad' onclick=\"window.location='{1}';\" ></div>", post.PicFileName, post.LinkUrl);
                }
            }

            ltlRight.Text = sb.ToString();
        }
    }
Example #18
0
    public String getMessagesMAXMIN()
    {
        if (Utility.currProjeto == null) return "var min = 0;var max = 100000;";

        String NumComps = Utility.currProjeto.getTemplateSetup("NCOMP");
        StringBuilder sb = new StringBuilder();

        if (Utility.currProjeto == null)
        {
            sb.Append("var min = 0;");
            sb.Append("var max = 100000;");
            return sb.ToString();
        }

        if (NumComps != "ALL")
        {
            int min, max;
            String[] MINMAX;
            MINMAX = NumComps.Replace("[", "").Replace("]", "").Split(',');
            min = int.Parse(MINMAX[0]);
            max = int.Parse(MINMAX[1]);

            sb.AppendFormat("var MensagemSelectedMIN = \"{0}\";", String.Format(dic.getResource(296), min.ToString(), max.ToString()));
            sb.AppendFormat("var MensagemSelectedMAX = \"{0}\";", String.Format(dic.getResource(296), min.ToString(), max.ToString()));
            sb.AppendFormat("var min = \"{0}\";", min.ToString());
            sb.AppendFormat("var max = \"{0}\";", max.ToString());
            return sb.ToString();
        }
        else
        {
            sb.Append("var min = 0;");
            sb.Append("var max = 100000;");
            return sb.ToString();
        }
    }
Example #19
0
    public static string Data_ToString(SerializeData data)
    {
        StringBuilder str = new StringBuilder();
        string name = data.property["Name"];
        str.AppendFormat("<{0} ", name);
        data.property.Remove("Name");
        foreach (var item in data.property)
        {
            str.AppendFormat("{0}=\"{1}\" ", item.Key, item.Value);
        }
        if (string.IsNullOrEmpty(data.childs_self))
        {
            str.Append("/>\r\n");
        }
        else
        {
            str.AppendFormat(">\r\n{0}</{1}>\r\n", data.childs_self, name);
        }

        foreach (var item in data.childs)
        {
            for (int i = 0; i < item.Value.Count; i++)
            {
                str.Append(Data_ToString(item.Value[i]));
            }
        }
        return str.ToString();
    }
Example #20
0
    private void PostToUrl(string URL, NameValueCollection col)
    {
        try
        {

            Response.Clear();

            StringBuilder sb = new StringBuilder();
            sb.Append("<html>");
            sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
            sb.AppendFormat("<form name='form' action='{0}' method='post'>", URL);
            foreach (string a in col)
            {
                sb.AppendFormat("<input type='hidden' name='{0}' value='{1}' />", a, col[a]);
            }
            sb.Append("</form>");
            sb.Append("</body>");
            sb.Append("</html>");

            Response.Write(sb.ToString());

            Response.End();

        }
        catch (Exception ex)
        {
            return;
        }
    }
 static void PolynomSum(int[] firstPol, int[] secondPol)
 {
     List<int> sumPol = new List<int>();
     if (firstPol.Length >= secondPol.Length)
     {
         for (int i = 0; i < firstPol.Length; i++)
         {
             sumPol.Add(firstPol[i] + secondPol[i]);
         }
     }
     else
     {
         for (int i = 0; i < secondPol.Length; i++)
         {
             sumPol.Add(firstPol[i] + secondPol[i]);
         }
     }
     StringBuilder strSumPol = new StringBuilder();
     if (sumPol[0] != 0)
     {
         strSumPol.AppendFormat("{0} ", sumPol[0]);
     }
     for (int i = 1; i < sumPol.Count; i++)
     {
         if (sumPol[i] != 0 && sumPol[i] > 0)
         {
             strSumPol.AppendFormat("+ {0}x^{1} ", sumPol[i], i);
         }
         if (sumPol[i] < 0)
         {
             strSumPol.AppendFormat("{0}x^{1} ", sumPol[i], i);
         }
     }
     Console.WriteLine(strSumPol.ToString());
 }
Example #22
0
    private string buildMenu(string currentPage)
    {
        StringBuilder menu = new StringBuilder();

        foreach (var parentPage in BlogEngine.Core.Page.Pages.Where(p => !p.HasParentPage))
        {
            menu.AppendFormat("<li class=\"page_item\"><a href=\"{0}\" title=\"{1}\">{1}</a>", parentPage.RelativeLink, parentPage.Title);

            if (parentPage.HasChildPages)
            {
                menu.Append("<ul class=\"sub-menu\">");
                foreach (
                    var childPage in
                        BlogEngine.Core.Page.Pages.Where(p => p.Parent == parentPage.Id))
                {
                    menu.AppendFormat(
                        "<li class=\"page_item\"><a href=\"{0}\" title=\"{1}\">{1}</a></li>",
                        childPage.RelativeLink, childPage.Title);
                }
                menu.AppendFormat("</ul>");
            }

            menu.Append("</li>");
        }

        return menu.ToString();
    }
Example #23
0
    private void PrepareAndSendEmail()
    {
        StringBuilder template = new StringBuilder(AppUtil.ReadEmailTemplate(AppConstants.EmailTemplate.GENERAL_EMAIL_TEMPLATE));
        if (template.Length > 0)
        {
            String senderName = SessionCache.CurrentUser == null ?
                        String.Format("{0}", AppUtil.Encode(txtName.Text.Trim()))
                        : String.Format("{0} {1} ({2})", AppUtil.Encode(SessionCache.CurrentUser.FirstName), AppUtil.Encode(SessionCache.CurrentUser.LastName), AppUtil.Encode(SessionCache.CurrentUser.Username));

            String toEmail = SessionCache.CurrentUser == null ?
                        String.Format("{0} <{1}>", senderName, txtEmail.Text.Trim())
                        : String.Format("{0} <{1}>", senderName, SessionCache.CurrentUser.Author_email);
            String fromEmail = ConfigReader.SupportEmail;
            String subject = AppUtil.Encode(txtSubject.Text.Trim());
            StringBuilder body = new StringBuilder(AppUtil.FormatText(txtComment.Text.Trim()));
            body.Append("<br /><br />");
            body.AppendFormat("<b>Sent By:</b> {0} <br />", senderName);
            body.AppendFormat("<b>From IP:</b> {0} <br />", AppUtil.GetRemoteIPAddress());

            template.Replace(AppConstants.ETConstants.MESSAGE, body.ToString());

            try
            {
                MailManager.SendMail(toEmail, String.Empty, String.Empty, fromEmail, subject, template.ToString());
            }
            catch { }
        }
    }
Example #24
0
    void Update()
    {
        elapsed += Time.deltaTime;
        if (elapsed > 1f)
        {
            elapsed = 0f;
            var sb = new StringBuilder();
            elapsed = 0f;
            Vector3 v = new Vector3(2, 3, 6);
            Vector3 w = new Vector3(7, 23, 1);

            var n = v.normalized;
            object[] arr = new object[] { n.x, n.y, n.z };
            Debug.Log(sb.AppendFormat("v.normalized = ({0}, {1}, {2})", arr).ToString());

            sb.Remove(0, sb.Length);
            var cross = Vector3.Cross(v, w);
            arr = new object[] { cross.x, cross.y, cross.z };
            Debug.Log(sb.AppendFormat("Cross(v, w) = ({0}, {1}, {2})", arr).ToString());

            Debug.Log("v.magnitude = " + v.magnitude);
            Debug.Log("w.magnitude = " + w.magnitude);
            Debug.Log("Dot(v, w) = " + Vector3.Dot(v, w));
            Debug.Log("Angle(v, w) = " + Vector3.Angle(v, w));

            var proj = Vector3.Project(v, w);
            Debug.Log("Project(v,w) = " + proj.ToString());

            v.Normalize();
            w.Normalize();
            Debug.Log("normalized v = " + v.ToString());
            Debug.Log("normalized w = " + w.ToString());
        }
	}
    public static string PrintBoardContent(int[,] board, string bgcolor,
		bool printTableEnd)
    {
        StringBuilder wr = new StringBuilder ();

        if (bgcolor == null) {
            wr.Append ("<table>");
        } else {
            wr.AppendFormat ("<table bgcolor=\"{0}\">", bgcolor);
        }

        wr.Append ("        <tr><td></td>");
        for (int x = 0 ; x < board.GetLength(1) ; ++x)
            wr.AppendFormat ("<td>{0}</td>", "abcdefghijklmnopqrstuvwxyz"[x]);
        wr.Append ("</tr>\n");

        for (int y = 0 ; y < board.GetLength(0) ; ++y) {
            wr.Append ("        <tr>");

            wr.AppendFormat ("<td>{0}</td>", y);
            for (int x = 0 ; x < board.GetLength(1) ; ++x) {
                wr.AppendFormat ("<td bgcolor=\"{0}\">+</td>",
                    board[y,x] == 1 ? OneColor :
                        (board[y,x] == -1 ? MOneColor : FreeColor));
            }
            wr.Append ("\n");
            wr.Append ("        </tr>\n");
        }
        if (printTableEnd)
            wr.Append ("        </table>\n");

        return (wr.ToString ());
    }
    private void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            // Do a raycast to find our selected tile
            Camera mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
            Vector2 position = mainCamera.ScreenToWorldPoint(Input.mousePosition);

            RaycastHit2D hit = Physics2D.Raycast(position, Vector2.zero, 0);
            if (hit)
            {
                StrategyTile tile = hit.collider.gameObject.GetComponent<StrategyTile>();
                tile.NumberOfClicks++;

                StringBuilder info = new StringBuilder();
                info.AppendFormat("Tile: {0}", tile.TileType);
                info.AppendLine();
                info.Append(tile.TileNote);
                info.AppendLine();
                info.AppendFormat("Clicks: {0}", tile.NumberOfClicks);
                this.uiText.text = info.ToString();
            }
            else
            {
                this.uiText.text = "No tile selected";
            }

            // Place the cursor
            GameObject cursor = GameObject.FindGameObjectWithTag("Cursor");
            position.x -= position.x % 16;
            position.y -= position.y % 16;
            cursor.transform.position = position;

        }
    }
Example #27
0
    private void BindTopic()
    {
        string fields = "[t_id],[t_title],[t_read_cnt],[t_reply_cnt],[r_uptime],[g_id],[g_name]";
        string where = "[r_t_id]=[t_id] and [g_id]=[t_g_id] and [r_user_name]='" + username + "'";

        string sqlc = "select count(*) from [restore] where [r_user_name]='" + username + "'";
        int cnt = (int)DB.GetValue(sqlc);
        if (cnt == 0) return;

        pageCount = cnt / pageSize;
        if (cnt % pageSize > 0) pageCount++;
        pageIndex = Math.Max(0, pageIndex);
        pageIndex = Math.Min(pageCount - 1, pageIndex);

        DataTable dt = Data.GetPagingData("[restore],[topic],[group]", fields, "[r_uptime]", "[t_id]", pageIndex, pageSize, where, true);

        StringBuilder sb = new StringBuilder();
        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div class='topicitem'>");
            sb.AppendFormat("<a class='bold' href='/group/topic/{0}{1}'>{2}</a>", row["t_id"], Settings.Ext, Tools.HtmlEncode(row["t_title"].ToString()));
            sb.AppendFormat(" <a class='hui' href='/group/{0}{1}'>[{2}]</a>", row["g_id"], Settings.Ext, Tools.HtmlEncode(row["g_name"].ToString()));
            sb.AppendFormat("<p class='em'>浏览({0}) 回复({1}) 回复于 {2}</p>", row["t_read_cnt"], row["t_reply_cnt"], Tools.DateString(row["r_uptime"].ToString()));
            sb.Append("</div>");
        }
        lblMsgList.Text = sb.ToString();

        if (pageCount > 1)
        {
            string url = "/groups/reply/{0}" + Settings.Ext;

            lblPageList.Text = Tools.GetPager(pageIndex, pageCount, pageNumber, url);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder strLog = new StringBuilder();
        strLog.AppendFormat("OpenBestToneAccountV2:Page_Load");
        ParseSPTokenRequest();

        if (Result == 0)
        {

            strLog.AppendFormat(String.Format("CustID:{0},SPID{1},HeadFooter:{2},ReturnUrl:{3}", CustID, SPID, HeadFooter, ReturnUrl));
            this.myCustID.Value = CustID;
            this.myReturnUrl.Value = ReturnUrl;
            this.HiddenField_SPID.Value = SPID;
            if ("yes".Equals(HeadFooter))
            {
                this.header.Visible = true;
                this.footer.Visible = true;
            }
            else
            {
                this.header.Visible = false;
                this.footer.Visible = false;
            }

            phoneNum = this.mobile.Text;
            this.hidCheckMobile.Value = this.mobile.Text;
        }
        else
        {
            Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);

        }

        log(strLog.ToString());
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            int n, nResult1, nResult2;
            string cValor;
            StringBuilder sb = new StringBuilder();

            // Testes genéricos
            cValor = "29875782123";
            nResult1 = Funcoes.Modulo11Padrao(cValor, 9);
            nResult2 = Funcoes.Modulo11Especial(cValor, 9);
            sb.AppendFormat("<b>Exemplo Unibanco Pag 55-56: {0} => {1} , {2}</b><br>", cValor, nResult1, nResult2);

            // Teste de Geração em Massa
            sb.Append("<br><hr>");
            for (n = 0; n < 1000; n++)
            {
                cValor = n.ToString();
                nResult1 = Funcoes.Modulo11Padrao(cValor, 9);
                nResult2 = Funcoes.Modulo11Especial(cValor, 9);
                if (nResult1 == nResult2)
                    sb.AppendFormat("{0} => {1} , {2}<br>", cValor, nResult1, nResult2);
                else
                    sb.AppendFormat("<b>{0} => {1} , {2} </b><br>", cValor, nResult1, nResult2);
            }
            this.lblResult.Text = sb.ToString();
        }
    }
Example #30
0
 /// <summary>
 /// Each Group item represents a named capture group defined in the pattern. 
 /// This function can be used to parse and re-assemble each url into a template used in indexing by replacing each 
 /// Within each group the actual values captured by the pattern are collected.
 /// "Url" is the complete address of an Item in a parsed collection of JSON elements.
 /// "Node" represents each object or array within the hierarchy of the URL.
 /// "NodeKey" represents UUID for each object or array providing ownership and identifiable differences within a collection of the same.
 /// "itemKey" is the key in the key/value pair of any Json element.
 /// </summary>
 /// <param name="url">JsonUrl for a parsed Json element</param>
 //[SqlFunction()]
 public static String TemplateJsonUrl(String url)
 {
     StringBuilder template = new StringBuilder();
     string[] groups = rxUrl.GetGroupNames();
     foreach (Match m in rxUrl.Matches(url))
     {
         /*step through each object extracted from the url and reassemble it, replacing the UUID's with placeholders*/
         foreach (string s in groups)
         {
             Group g = m.Groups[s];
             CaptureCollection cc = g.Captures;
             foreach (Capture cap in cc)
             {
                 /*If this is a captured Node from the Url.*/
                 if (String.Equals(s, "node", sc))
                 {
                     template.AppendFormat(".{0}[{1}]", cap.Value, "{0}");
                 }
                 /*If this is a captured itemKey from the Url.*/
                 if (String.Equals(s, "itemKey", sc))
                 {
                     template.AppendFormat(".{0}", cap.Value);
                 }
             }
         }
     }
     return template.ToString();
 }