Beispiel #1
0
 public void WriteCache(string userNick, ProcessDetail value)
 {
     if (currentCahce == null)
     {
         currentCahce = System.Web.HttpRuntime.Cache;
     }
     //currentCahce.Add(userNick, value, null, System.DateTime.Now, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null);
     currentCahce[userNick] = value;
 }
Beispiel #2
0
        //ImageCompression comporession = new ImageCompression();
        public override void SetWirelessDesc(string userNick, int curr, int total, string gender, string imageHandler, Func <string, Int64, string> genderImageCompleteCallBack)
        {
            switch (gender)
            {
            case "true":
                if (!string.IsNullOrEmpty(this.WirelessDesc))
                {
                    return;
                }
                break;
            }
            var           matches    = System.Text.RegularExpressions.Regex.Matches(this.Description, parrent, RegexOptions.IgnoreCase);
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append("<wapDesc>");
            var i      = 0;
            int weight = 0;
            /*处理后的图片总量不能超过1572864*/
            ProcessDetail details = new ProcessDetail();

            foreach (Match item in matches)
            {
                try
                {
                    if (weight >= 1572864)
                    {
                        break;
                    }
                    details.Curr    = curr;
                    details.Total   = total;
                    details.Process = ((i) / Convert.ToSingle(matches.Count)) + (curr / Convert.ToSingle(total)) * 100;
                    UserProcessRepoter.Instance[userNick] = details;
                    var     res          = item.Groups[1].Value;
                    Boolean isSuccess    = true;
                    var     handFilePath = ImageHandler.ImageHandlerClient.Handler(res, this.UserName, gender, imageHandler, ref isSuccess, ref weight);
                    if (!isSuccess)
                    {
                        weight += weight; continue;
                    }
                    ;
                    if (genderImageCompleteCallBack != null)
                    {
                        if (string.IsNullOrEmpty(handFilePath))
                        {
                            continue;
                        }
                        var pictureInfo = new FileInfo(handFilePath);
                        weight += Convert.ToInt32(pictureInfo.Length);
                        if (pictureInfo.Length < 1845)
                        {
                            continue;
                        }
                        var filePath = genderImageCompleteCallBack(handFilePath, Convert.ToInt64(this.NumId));

                        strBuilder.Append("<img>" + filePath + "</img>");
                        try
                        {
                            if (File.Exists(handFilePath))
                            {
                                File.Delete(handFilePath);
                            }
                            if (File.Exists(res))
                            {
                                File.Delete(res);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    i++;
                }
                catch (Exception ex)
                {
                    continue;
                }
                strBuilder.Append("</wapDesc>");
                this.WirelessDesc = strBuilder.ToString();
            }
        }