コード例 #1
0
        /// <summary>
        /// Given a list of points, find a circle that roughly passes through them all.
        /// </summary>
        public static CircleSegment ComputeCircle(System.Collections.Generic.IEnumerable <Point2d> l)
        {
            // https://www.scribd.com/document/14819165/Regressions-coniques-quadriques-circulaire-spherique
            // via http://math.stackexchange.com/questions/662634/find-the-approximate-center-of-a-circle-passing-through-more-than-three-points

            var n     = l.Count();
            var sumx  = l.Sum(p => p.X);
            var sumxx = l.Sum(p => p.X * p.X);
            var sumy  = l.Sum(p => p.Y);
            var sumyy = l.Sum(p => p.Y * p.Y);

            var d11 = n * l.Sum(p => p.X * p.Y) - sumx * sumy;

            var d20 = n * sumxx - sumx * sumx;
            var d02 = n * sumyy - sumy * sumy;

            var d30 = n * l.Sum(p => p.X * p.X * p.X) - sumxx * sumx;
            var d03 = n * l.Sum(p => p.Y * p.Y * p.Y) - sumyy * sumy;

            var d21 = n * l.Sum(p => p.X * p.X * p.Y) - sumxx * sumy;
            var d12 = n * l.Sum(p => p.Y * p.Y * p.X) - sumyy * sumx;

            var x = ((d30 + d12) * d02 - (d03 + d21) * d11) / (2 * (d20 * d02 - d11 * d11));
            var y = ((d03 + d21) * d20 - (d30 + d12) * d11) / (2 * (d20 * d02 - d11 * d11));

            var c = (sumxx + sumyy - 2 * x * sumx - 2 * y * sumy) / n;
            var r = Math.Sqrt(c + x * x + y * y);

            return(new CircleSegment(new Point2f((float)x, (float)y), (float)r));
        }
コード例 #2
0
        public static string ToFormatString(this System.Collections.Generic.IEnumerable <StrObjectDict> records, string rowSpliter, string format)
        {
            string result = string.Empty;
            int    num    = records.Count <StrObjectDict>();

            if (num > 0)
            {
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                Regex           regex           = new Regex("%([0-9A-Za-z_]*)%");
                MatchCollection matchCollection = regex.Matches(format);
                System.Collections.Generic.List <string> list  = new System.Collections.Generic.List <string>();
                System.Collections.Generic.List <string> list2 = new System.Collections.Generic.List <string>();
                foreach (Match match in matchCollection)
                {
                    string text = match.Groups[1].Value.ToUpper();
                    format = format.Replace(match.Groups[1].Value, text);
                    list2.Add(text);
                }
                string text2 = format;
                foreach (StrObjectDict current in records)
                {
                    foreach (string current2 in list2)
                    {
                        text2 = text2.Replace("%" + current2 + "%", current[current2].ToString());
                    }
                    list.Add(text2);
                    text2 = format;
                }
                result = string.Join(rowSpliter, list.ToArray());
            }
            return(result);
        }
コード例 #3
0
        public Rectangle Layout(Graphics graphics, ISimpleContainer container)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            BaseReportItem containerItem = container as BaseReportItem;
//			container.Items.SortByLocation();
            Rectangle desiredContainerRectangle = new Rectangle(containerItem.Location, containerItem.Size);

            System.Collections.Generic.IEnumerable <BaseReportItem> canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt;

            if (canGrowShrinkCollection.Count() > 0)
            {
                int       extend         = containerItem.Size.Height - canGrowShrinkCollection.First().Size.Height;
                Rectangle surroundingRec = FindSurroundingRectangle(graphics, canGrowShrinkCollection);

                if (surroundingRec.Height > desiredContainerRectangle.Height)
                {
                    desiredContainerRectangle = new Rectangle(containerItem.Location.X,
                                                              containerItem.Location.Y,
                                                              containerItem.Size.Width,
                                                              surroundingRec.Size.Height + extend);
                }
            }

            return(desiredContainerRectangle);
        }
コード例 #4
0
ファイル: Layouter.cs プロジェクト: windcatcher/SharpDevelop
        public Rectangle Layout(Graphics graphics, ISimpleContainer container)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (container.Items == null)
            {
                return(Rectangle.Empty);
            }

            Rectangle desiredContainerRectangle = new Rectangle(container.Location, container.Size);

            System.Collections.Generic.IEnumerable <BaseReportItem> canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt;

            if (canGrowShrinkCollection.Count() > 0)
            {
                Rectangle surroundingRec = FindSurroundingRectangle(graphics, canGrowShrinkCollection);
                desiredContainerRectangle = new Rectangle(container.Location.X,
                                                          container.Location.Y,
                                                          container.Size.Width,
                                                          surroundingRec.Size.Height);
            }
            return(desiredContainerRectangle);
        }
コード例 #5
0
            public override object GetIndex(Func <object> proceed, object self, System.Collections.Generic.IEnumerable <object> keys)
            {
                if (keys.Count() == 1)
                {
                    // Here's the new bit
                    var key = System.Convert.ToString(keys.Single());

                    // Check for the proxy symbol
                    if (key.Contains("@"))
                    {
                        // Find the proxy!
                        var split = key.Split('@');
                        // Access the proxy shape
                        return(_Proxies[split[0]]()
                               // Find the right zone on it
                               .Zones[split[1]]);
                    }
                    else
                    {
                        // Otherwise, defer to the ZonesBehavior activator, which we made available
                        // This will always return a ZoneOnDemandBehavior for the local shape
                        return(_zonesActivator()[key]);
                    }
                }
                return(proceed());
            }
コード例 #6
0
        private void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.litNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
            }
            else
            {
                this.pnlShopCart.Visible  = true;
                this.litNoProduct.Visible = false;
                if (shoppingCart.LineItems.Values.Count > 0)
                {
                    this.shoppingCartProductList.DataSource = shoppingCart.LineItems.Values;
                    this.shoppingCartProductList.DataBind();
                    this.shoppingCartProductList.ShowProductCart();
                }
                if (shoppingCart.LineGifts.Count > 0)
                {
                    System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
                        from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
                        where shoppingCartGiftInfo_0.PromoType == 0
                        select shoppingCartGiftInfo_0;
                    System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
                        from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
                        where shoppingCartGiftInfo_0.PromoType == 5
                        select shoppingCartGiftInfo_0;
                    this.shoppingCartGiftList.DataSource     = enumerable;
                    this.shoppingCartGiftList.FreeDataSource = enumerable2;
                    this.shoppingCartGiftList.DataBind();
                    this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
                }
                if (shoppingCart.IsSendGift)
                {
                    int num = 1;
                    int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift);
                    System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts();
                    if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0)
                    {
                        this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts;
                        this.shoppingCartPromoGiftList.DataBind();
                        this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num);
                    }
                }
                if (shoppingCart.IsReduced)
                {
                    this.lblAmoutPrice.Text              = string.Format("商品金额:{0}", shoppingCart.GetAmount().ToString("F2"));
                    this.hlkReducedPromotion.Text        = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
                    this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
                    {
                        shoppingCart.ReducedPromotionId
                    });
                }
                this.lblTotalPrice.Money = shoppingCart.GetTotal();
            }
        }
コード例 #7
0
 public override object GetIndex(Func <object> proceed, object self, System.Collections.Generic.IEnumerable <object> keys)
 {
     if (keys.Count() == 1)
     {
         return(GetMember(proceed, null, System.Convert.ToString(keys.Single())));
     }
     return(proceed());
 }
コード例 #8
0
        public static bool FullMatch(Excel[] excels, DataRow[] rows)
        {
            bool result3;

            if (excels == null && rows != null)
            {
                result3 = false;
            }
            else
            {
                if (excels != null && rows == null)
                {
                    result3 = false;
                }
                else
                {
                    if (excels.Length != rows.Length)
                    {
                        result3 = false;
                    }
                    else
                    {
                        for (int i = 0; i < excels.Length; i++)
                        {
                            Excel ea = excels[i];
                            System.Collections.Generic.IEnumerable <DataRow> result = rows.Where(delegate(DataRow m)
                            {
                                string ID = m.Field <string>("DEBH");
                                return(ID.EqualsNo(ea.QDBH));
                            });
                            if (result == null || result.Count <DataRow>() < 1)
                            {
                                result3 = false;
                                return(result3);
                            }
                        }
                        for (int i = 0; i < rows.Length; i++)
                        {
                            DataRow row = rows[i];
                            string  ID  = row.Field <string>("DEBH");
                            System.Collections.Generic.IEnumerable <Excel> result2 =
                                from m in excels
                                where ID.EqualsNo(m.QDBH)
                                select m;
                            if (result2 == null || result2.Count <Excel>() < 1)
                            {
                                result3 = false;
                                return(result3);
                            }
                        }
                        result3 = true;
                    }
                }
            }
            return(result3);
        }
コード例 #9
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Parallel for each.
        /// </summary>
        /// <typeparam name="TSource">
        ///  Type of the source.
        /// </typeparam>
        /// <param name="source">
        ///  Source for the.
        /// </param>
        /// <param name="body">
        ///  The body.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public virtual void Parallel_ForEach <TSource>(System.Collections.Generic.IEnumerable <TSource> source, Action <TSource> body)
        {
            var tasks = new Task[source.Count()];
            var i     = 0;

            foreach (var s in source)
            {
                var tmp = s;
                tasks[i++] = Task.Run(() => body(tmp));
            }
            Task.WaitAll(tasks);
        }
コード例 #10
0
        private void DataBindCategoryCustom()
        {
            System.Collections.Generic.IEnumerable <CategoryInfo> enumerable =
                from info in CatalogHelper.GetMainCategories()
                where info.Theme != null && info.Theme != ""
                select info;

            if (enumerable.Count <CategoryInfo>() > 0)
            {
                this.rp_productype.DataSource = enumerable;
                this.rp_productype.DataBind();
            }
        }
コード例 #11
0
        public Rectangle Layout(Graphics graphics, ISimpleContainer container)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }


            if (container.Items == null)
            {
                return(Rectangle.Empty);
            }

//			Console.WriteLine("\tlayouter for container <{0}>",container.ToString());
            Console.WriteLine("\tLayouter for Container");
            Rectangle desiredContainerRectangle = new Rectangle(container.Location, container.Size);

            System.Collections.Generic.IEnumerable <BaseReportItem> canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt;

            if (canGrowShrinkCollection.Count() > 0)
            {
                Rectangle surroundingRec = FindSurroundingRectangle(graphics, canGrowShrinkCollection);
//				desiredContainerRectangle = new Rectangle(container.Location.X,
//				                                          container.Location.Y,
//				                                          container.Size.Width,
//				                                          surroundingRec.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom);
//
                desiredContainerRectangle = new Rectangle(container.Location.X,
                                                          container.Location.Y,
                                                          container.Size.Width,
                                                          surroundingRec.Size.Height);

//			var r1 = new Rectangle(container.Location.X,
//				                                          container.Location.Y,
//				                                          container.Size.Width,
//				                                          surroundingRec.Size.Height);
//
//				Console.WriteLine("Diff {0} - {1} dif  {2}",desiredContainerRectangle,r1,desiredContainerRectangle.Height - r1.Height);
            }
//			Console.WriteLine("\tContainer : {0} - DesiredContainerRectangle {1} ",container.Size,desiredContainerRectangle.Size);
            return(desiredContainerRectangle);
        }
コード例 #12
0
        // returns XYZ and ZOOM/FOV value


        public static string MakeUniqueFileName(string file, System.Collections.Generic.IEnumerable <View3D> views)
        {
            string fn;

            for (int i = 0; ; ++i)
            {
                fn = file + i.ToString();
                System.Collections.Generic.IEnumerable <View3D> m_nviews = from elem in views
                                                                           let type = elem as View3D
                                                                                      where type.Name == fn
                                                                                      select type;

                if (m_nviews.Count() == 0)
                {
                    return(fn);
                }
            }
        }
        public override void UpdateUser(MembershipUser _user)
        {
            var dbContext = new DBContext();
            MembershipPerson personData = (_user as MembershipPerson);
            User             usr        = dbContext.GetUser(personData.person.PersonID);

            if (usr == null)
            {
                usr        = new User();
                usr.Person = dbContext.GetPerson(personData.person.PersonID);
                if (usr.Person == null)
                {
                    return;
                }
            }
            usr.Person.Avatar    = personData.person.Avatar;
            usr.Person.Name      = personData.person.Name;
            usr.Person.Gender    = personData.person.Gender;
            usr.UserName         = personData.UserName;
            usr.UserEmailAddress = personData.Email;

            IQueryable <Photo> photos = (from p in dbContext.Photos where p.PersonID == usr.Person.PersonID select p);

            foreach (Photo p in photos)
            {
                System.Collections.Generic.IEnumerable <Photo> ps = personData.person.Photos.Select(x => x).Where(x => x.PhotoID == p.PhotoID);
                if (ps.Count() == 0)
                {
                    dbContext.Entry(p).State = System.Data.EntityState.Deleted;
                }
                else
                {
                    p.PhotoStream = ps.First().PhotoStream;
                }
            }
            IEnumerable <Photo> photosToAdd = personData.person.Photos.Where(x => x.PhotoID == 0).Select(x => x);

            foreach (Photo p in photosToAdd)
            {
                dbContext.AddPhoto(p);
            }
            dbContext.SaveChanges();
        }
コード例 #14
0
        public StatiticsViewModel()
        {
            newPlayer = new ObservableCollection <PlayerStatitics>();

            string player  = "";
            string imageid = "";
            string wins    = "";
            string losses  = "";


            System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("..\\..\\Players.txt");


            for (int j = 0; j < lines.Count(); j++)

            {
                string[] playerElements = lines.ElementAt(j).Split(' ');
                int      i = 1;
                foreach (string word in playerElements)
                {
                    if (i == 1)
                    {
                        player = word;
                    }
                    else if (i == 2)
                    {
                        imageid = word;
                    }
                    else if (i == 8)
                    {
                        wins = word;
                    }
                    else if (i == 9)
                    {
                        losses = word;
                    }

                    i++;
                    Console.WriteLine(word + "\t");
                }
                newPlayer.Add(new PlayerStatitics(player, imageid, wins, losses));
            }
        }
コード例 #15
0
ファイル: BOLResources.cs プロジェクト: ARGorji/Ranjbaran
    public DataTable GetValidAccess(List <AccessListStruct> AccessList, SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage)
    {
        DataTable        dt          = new DataTable();
        UsersDataContext dataContext = new UsersDataContext();
        string           WhereCond   = Tools.GetCondition(sFilterCols);

        if (HttpContext.Current.Session["UserCode"] != null)
        {
            //AccessListStruct s=new AccessListStruct("Edit",
            ArrayList EditAccess = new ArrayList();
            ArrayList ViewAccess = new ArrayList();

            for (int i = 0; i < AccessList.Count; i++)
            {
                if (AccessList[i].AccessName == "EDIT")
                {
                    EditAccess.Add(AccessList[i].FieldName);
                }
                else if (AccessList[i].AccessName == "VIEW")
                {
                    ViewAccess.Add(AccessList[i].FieldName);
                }
            }
            //string[] EditAccess = HttpContext.Current.Session["Edit"].ToString().Split(',');
            //string[] ViewAccess = HttpContext.Current.Session["View"].ToString().Split(',');
            string[] arrEditAccess = (string[])EditAccess.ToArray(typeof(string));
            string[] arrViewAccess = (string[])ViewAccess.ToArray(typeof(string));
            System.Collections.Generic.IEnumerable <String> AllAccess = arrEditAccess.Union(arrViewAccess);
            if (AllAccess.Count <string>() > 0)
            {
                var ListResult = from v in dataContext.Resources
                                 orderby v.Ordering
                                 where (v.HCResourceTypeCode.Equals(1) || v.HCResourceTypeCode.Equals(2)) &&
                                 (AllAccess.Contains(v.ResName))
                                 select v

                ;
                dt = new Converter <Resources>().ToDataTable(ListResult);
            }
        }
        return(dt);
    }
コード例 #16
0
        DoReadDataMapForListMapper(System.Collections.Generic.IEnumerable <AvServer> list)
        {
            List <ServerListViewModel> viewModelList = new List <ServerListViewModel>();
            int x = list.Count();

            foreach (var item in list)
            {
                ServerListViewModel viewModel = new ServerListViewModel();

                viewModel.Id           = item.Id;
                viewModel.ServerIp     = item.ServerIp;
                viewModel.Aciklama     = item.Aciklama;
                viewModel.ComputerName = item.ComputerName;


                viewModel.LokasyonAd        = item.Lokasyon.Ad;
                viewModel.ServerTipiAd      = item.ServerTipi.Ad;
                viewModel.OperatingSystemAd = item.OperatingSystem.Ad;
                viewModel.PingYapilsinMi    = item.PingYapilsinMi;
                viewModelList.Add(viewModel);
            }

            return(viewModelList);
        }
コード例 #17
0
ファイル: IEnumerable.cs プロジェクト: OliPerraul/mtlgj2020
 public static bool IsEmpty <T>(this System.Collections.Generic.IEnumerable <T> collection)
 {
     return(collection.Count() == 0);
 }
コード例 #18
0
ファイル: Helper.cs プロジェクト: wraikny/Altseed
 public static int CountIterable <TContent>(System.Collections.Generic.IEnumerable <TContent> contents)
 {
     return(contents.Count());
 }
コード例 #19
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            AccessTokenResult token = CommonApi.GetToken(SinGooCMS.Weixin.Config.AppID, SinGooCMS.Weixin.Config.AppSecret, "client_credential");

            System.Collections.Generic.List <WxMenuInfo>     list             = WxMenu.GetList(15, "", " RootID ASC,ParentID ASC,Sort ASC ") as System.Collections.Generic.List <WxMenuInfo>;
            System.Collections.Generic.Dictionary <int, int> repeaterSortDict = base.GetRepeaterSortDict(this.Repeater1, "txtsort", "autoid");
            foreach (WxMenuInfo current in list)
            {
                current.Sort = repeaterSortDict[current.AutoID];
            }
            list = (from p in list
                    orderby p.RootID
                    orderby p.ParentID
                    orderby p.Sort
                    select p).ToList <WxMenuInfo>();
            if (WxMenu.UpdateSort(repeaterSortDict))
            {
                PageBase.log.AddEvent(base.LoginAccount.AccountName, "更新微信菜单排序成功");
            }
            ButtonGroup buttonGroup = new ButtonGroup();

            foreach (WxMenuInfo level1 in list)
            {
                if (level1.ParentID.Equals(0))
                {
                    if (level1.ChildCount > 0)
                    {
                        SubButton subButton = new SubButton
                        {
                            name = level1.Name
                        };
                        System.Collections.Generic.IEnumerable <WxMenuInfo> enumerable = from p in list
                                                                                         where p.ParentID.Equals(level1.AutoID)
                                                                                         select p;
                        if (enumerable != null && enumerable.Count <WxMenuInfo>() > 0)
                        {
                            foreach (WxMenuInfo current2 in enumerable)
                            {
                                string type = current2.Type;
                                if (type != null)
                                {
                                    if (!(type == "click"))
                                    {
                                        if (type == "view")
                                        {
                                            subButton.sub_button.Add(new SingleViewButton
                                            {
                                                name = current2.Name,
                                                url  = current2.Url
                                            });
                                        }
                                    }
                                    else
                                    {
                                        subButton.sub_button.Add(new SingleClickButton
                                        {
                                            name = current2.Name,
                                            key  = current2.EventKey
                                        });
                                    }
                                }
                            }
                        }
                        buttonGroup.button.Add(subButton);
                    }
                    else
                    {
                        string type = level1.Type;
                        if (type != null)
                        {
                            if (!(type == "click"))
                            {
                                if (type == "view")
                                {
                                    buttonGroup.button.Add(new SingleViewButton
                                    {
                                        name = level1.Name,
                                        url  = level1.Url
                                    });
                                }
                            }
                            else
                            {
                                buttonGroup.button.Add(new SingleClickButton
                                {
                                    name = level1.Name,
                                    key  = level1.EventKey
                                });
                            }
                        }
                    }
                }
            }
            Senparc.Weixin.Entities.WxJsonResult wxJsonResult = Senparc.Weixin.MP.CommonAPIs.CommonApi.CreateMenu(token.access_token, buttonGroup, 10000);
            if (wxJsonResult.errcode == ReturnCode.请求成功)
            {
                PageBase.log.AddEvent(base.LoginAccount.AccountName, "更新微信菜单成功");
                base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
                this.BindData();
            }
            else
            {
                PageBase.log.AddErrLog("更新微信菜单出错了", wxJsonResult.errmsg);
                base.ShowAjaxMsg(this.UpdatePanel1, wxJsonResult.errmsg);
            }
        }
コード例 #20
0
        private ErrCode CheckXmlForRemoteItem(XDocument xDoc)
        {
            System.Collections.Generic.IEnumerable <XElement> enumerable = xDoc.Descendants("Item");
            ErrCode result;

            if (enumerable.Count <XElement>() == 0)
            {
                this.ErrCodeParse(ErrCode.xmlNoNode);
                result = ErrCode.xmlNoNode;
            }
            else
            {
                foreach (XContainer current in enumerable)
                {
                    if (!current.Elements().Any((XElement e) => e.Name == "TypeRW"))
                    {
                        goto IL_E8;
                    }
                    if (!current.Elements().Any((XElement e) => e.Name == "Name"))
                    {
                        goto IL_E8;
                    }
                    bool arg_EA_0 = current.Elements().Any((XElement e) => e.Name == "Addr");
IL_E9:
                    if (!arg_EA_0)
                    {
                        this.ErrCodeParse(ErrCode.xmlNoElement);
                        result = ErrCode.xmlNoElement;
                        return(result);
                    }
                    string value  = current.Element("Name").Value;
                    string value2 = current.Element("Addr").Value;
                    string text   = current.Element("TypeRW").Value.ToLower();
                    if (text != "read" && text != "write")
                    {
                        this._errItemName = text;
                        this.ErrCodeParse(ErrCode.xmlTypeRWFlt);
                        result = ErrCode.xmlTypeRWFlt;
                        return(result);
                    }
                    if (text == "read")
                    {
                        if (!this._items.AddrRead.ContainsKey(value) || !this._items.NameRead.ContainsKey(value2))
                        {
                            this._errItemName = value;
                            this._errItemAddr = value2;
                            this.ErrCodeParse(ErrCode.noNameOrAddr);
                            result = ErrCode.noNameOrAddr;
                            return(result);
                        }
                    }
                    if (text == "write")
                    {
                        if (!this._items.AddrWrite.ContainsKey(value) || !this._items.NameWrite.ContainsKey(value2))
                        {
                            this._errItemName = value;
                            this._errItemAddr = value2;
                            this.ErrCodeParse(ErrCode.noNameOrAddr);
                            result = ErrCode.noNameOrAddr;
                            return(result);
                        }
                    }
                    continue;
IL_E8:
                    arg_EA_0 = false;
                    goto IL_E9;
                }
                result = ErrCode.ok;
            }
            return(result);
        }
コード例 #21
0
ファイル: Register.cs プロジェクト: ngochoanhbr/dahuco
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (base.IsPost)
            {
                RegType regType      = (RegType)System.Enum.Parse(typeof(RegType), WebUtils.GetFormString("_regtype", "Normal"));
                string  strGroupName = WebUtils.GetFormString("_usergroupname", "个人会员");
                System.Collections.Generic.IEnumerable <UserGroupInfo> source = from p in UserGroup.GetCacheUserGroupList()
                                                                                where p.GroupName.Equals(strGroupName)
                                                                                select p;
                System.Collections.Generic.IEnumerable <UserLevelInfo> source2 = (from p in UserLevel.GetCacheUserLevelList()
                                                                                  orderby p.Integral
                                                                                  select p).Take(1);
                TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP());
                UserInfo       userInfo         = new UserInfo
                {
                    UserName      = WebUtils.GetFormString("_regname"),
                    Password      = WebUtils.GetFormString("_regpwd"),
                    GroupID       = ((source.Count <UserGroupInfo>() > 0) ? source.First <UserGroupInfo>().AutoID : 0),
                    LevelID       = ((source2.Count <UserLevelInfo>() > 0) ? source2.First <UserLevelInfo>().AutoID : 0),
                    Email         = ((regType == RegType.ByEmail) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regemail")),
                    Mobile        = ((regType == RegType.ByMobile) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regmobile")),
                    Country       = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country),
                    Province      = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.region),
                    City          = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.city),
                    County        = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country),
                    Status        = 99,
                    AutoTimeStamp = System.DateTime.Now
                };
                string[] array = PageBase.config.SysUserName.Split(new char[]
                {
                    ','
                });
                string strA = string.Empty;
                switch (regType)
                {
                case RegType.ByMobile:
                {
                    SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Mobile);
                    if (lastCheckCode != null)
                    {
                        strA = lastCheckCode.ValidateCode;
                    }
                    goto IL_27A;
                }

                case RegType.ByEmail:
                {
                    SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Email);
                    if (lastCheckCode != null)
                    {
                        strA = lastCheckCode.ValidateCode;
                    }
                    goto IL_27A;
                }
                }
                strA = base.ValidateCode;
IL_27A:
                if (PageBase.config.VerifycodeForReg && string.Compare(strA, WebUtils.GetFormString("_regyzm"), true) != 0)
                {
                    base.WriteJsonTip(base.GetCaption("ValidateCodeIncorrect"));
                }
                else if (userInfo.GroupID.Equals(0) || userInfo.LevelID.Equals(0))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MemberInfoNotComplete"));
                }
                else if (!SinGooCMS.BLL.User.IsValidUserName(userInfo.UserName) && !ValidateUtils.IsEmail(userInfo.UserName) && !ValidateUtils.IsMobilePhone(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_InvalidUserName"));
                }
                else if (array.Length > 0 && array.Contains(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_SystemRetainsUserName").Replace("${username}", userInfo.UserName));
                }
                else if (SinGooCMS.BLL.User.IsExistsByName(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_UserNameAlreadyExists"));
                }
                else if (userInfo.Password.Length < 6)
                {
                    base.WriteJsonTip(base.GetCaption("Reg_UserPwdLenNeed"));
                }
                else if (userInfo.Password != WebUtils.GetFormString("_regpwdagain"))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_2PwdInputNoMatch"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && !ValidateUtils.IsEmail(userInfo.Email))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_EmailTypeError"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && SinGooCMS.BLL.User.IsExistsByEmail(userInfo.Email))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_EmailAddressAlreadyExists"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && !ValidateUtils.IsMobilePhone(userInfo.Mobile))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MobileTypeError"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && SinGooCMS.BLL.User.IsExistsByMobile(userInfo.Mobile))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MobileAlreadyExists"));
                }
                else
                {
                    int autoID = 0;
                    System.Collections.Generic.IList <UserFieldInfo> fieldListByModelID      = UserField.GetFieldListByModelID(userInfo.GroupID, true);
                    System.Collections.Generic.Dictionary <string, UserFieldInfo> dictionary = new System.Collections.Generic.Dictionary <string, UserFieldInfo>();
                    foreach (UserFieldInfo current in fieldListByModelID)
                    {
                        current.Value = WebUtils.GetFormString(current.FieldName);
                        dictionary.Add(current.FieldName, current);
                    }
                    UserStatus userStatus = SinGooCMS.BLL.User.Reg(userInfo, dictionary, ref autoID);
                    if (userStatus.Equals(UserStatus.Success))
                    {
                        new MsgService(userInfo).SendRegMsg();
                        new MsgService().SendRegMsg2Mger();
                        if (PageBase.config.RegGiveIntegral > 0)
                        {
                            userInfo.AutoID = autoID;
                            AccountDetail.AddIntegral(userInfo, 1, (double)PageBase.config.RegGiveIntegral, "注册赠送积分");
                        }
                        UserInfo    userInfo2   = new UserInfo();
                        LoginStatus loginStatus = SinGooCMS.BLL.User.UserLogin(userInfo.UserName, userInfo.Password, ref userInfo2);
                        string      text        = base.Server.UrlDecode(WebUtils.GetFormString("_regreturnurl"));
                        if (!string.IsNullOrEmpty(text))
                        {
                            base.WriteJsonTip(true, base.GetCaption("Reg_Success"), text);
                        }
                        else
                        {
                            base.WriteJsonTip(true, base.GetCaption("Reg_Success"), "/user/regsuccess.html?info=" + base.Server.UrlEncode(base.GetCaption("Reg_SuccessWillJumpMemberCenter")));
                        }
                    }
                    else
                    {
                        base.WriteJsonTip(base.GetCaption("Reg_FailWithMsg").Replace("${msg}", base.GetCaption("UserStatus_" + userStatus.ToString())));
                    }
                }
            }
            else
            {
                System.Collections.Generic.IEnumerable <UserGroupInfo> source3 = from p in UserGroup.GetCacheUserGroupList()
                                                                                 where p.GroupName.Equals("个人会员")
                                                                                 select p;
                base.Put("usermodel", UserField.GetFieldListByModelID((source3.Count <UserGroupInfo>() > 0) ? source3.First <UserGroupInfo>().AutoID : 0, true));
                base.Put("returnurl", WebUtils.GetQueryString("returnurl"));
                base.UsingClient("user/注册.html");
            }
        }
コード例 #22
0
        private void DoSmth(object obj)
        {
            Players = new ObservableCollection <PlayerStatitics>();
            string player  = "";
            string imageid = "";
            string wins    = "";
            string losses  = "";

            System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("..\\..\\Players.txt");

            if (obj.ToString() == "All-categories")
            {
                lines = File.ReadLines("..\\..\\AllCategories.txt");
            }
            if (obj.ToString() == "Animals")
            {
                lines = File.ReadLines("..\\..\\Animals.txt");
            }
            if (obj.ToString() == "Astronomy")
            {
                lines = File.ReadLines("..\\..\\Astronomy.txt");
            }
            if (obj.ToString() == "Cars")
            {
                lines = File.ReadLines("..\\..\\Cars.txt");
            }
            if (obj.ToString() == "Movies")
            {
                lines = File.ReadLines("..\\..\\Movies.txt");
            }
            if (obj.ToString() == "Music")
            {
                lines = File.ReadLines("..\\..\\Music.txt");
            }

            for (int j = 0; j < lines.Count(); j++)

            {
                string[] playerElements = lines.ElementAt(j).Split(' ');
                int      i = 1;
                foreach (string word in playerElements)
                {
                    if (i == 1)
                    {
                        Console.WriteLine("Player:");
                        player = word;
                    }
                    else if (i == 2)
                    {
                        imageid = word;
                    }
                    else if (i == 3)
                    {
                        wins = word;
                    }
                    else if (i == 4)
                    {
                        losses = word;
                    }
                    i++;
                }
                Players.Add(new PlayerStatitics(player, imageid, wins, losses));
            }
        }
コード例 #23
0
 private void BindShoppingCartInfo(ShoppingCartInfo shoppingCart)
 {
     if (shoppingCart.LineItems.Values.Count > 0)
     {
         this.cartProductList.DataSource = shoppingCart.LineItems.Values;
         this.cartProductList.DataBind();
         this.cartProductList.ShowProductCart();
     }
     if (shoppingCart.LineGifts.Count > 0)
     {
         System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
             from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
             where shoppingCartGiftInfo_0.PromoType == 0
             select shoppingCartGiftInfo_0;
         System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
             from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
             where shoppingCartGiftInfo_0.PromoType == 5
             select shoppingCartGiftInfo_0;
         this.cartGiftList.DataSource     = enumerable;
         this.cartGiftList.FreeDataSource = enumerable2;
         this.cartGiftList.DataBind();
         this.cartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
     }
     if (shoppingCart.IsReduced)
     {
         this.litProductAmount.Text           = string.Format("商品金额:{0}", Globals.FormatMoney(shoppingCart.GetAmount()));
         this.hlkReducedPromotion.Text        = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
         this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
         {
             shoppingCart.ReducedPromotionId
         });
     }
     if (shoppingCart.IsFreightFree)
     {
         this.hlkFeeFreight.Text        = string.Format("({0})", shoppingCart.FreightFreePromotionName);
         this.hlkFeeFreight.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
         {
             shoppingCart.FreightFreePromotionId
         });
     }
     this.lblTotalPrice.Money = shoppingCart.GetTotal();
     this.lblOrderTotal.Money = shoppingCart.GetTotal();
     this.litPoint.Text       = shoppingCart.GetPoint().ToString();
     if (this.isBundling)
     {
         BundlingInfo bundlingInfo = ProductBrowser.GetBundlingInfo(this.bundlingid);
         this.lblTotalPrice.Money     = bundlingInfo.Price;
         this.lblOrderTotal.Money     = bundlingInfo.Price;
         this.litPoint.Text           = shoppingCart.GetPoint(bundlingInfo.Price).ToString();
         this.litProductBundling.Text = "(捆绑价)";
     }
     this.litAllWeight.Text = shoppingCart.Weight.ToString();
     if (shoppingCart.IsSendTimesPoint)
     {
         this.hlkSentTimesPoint.Text        = string.Format("({0};送{1}倍)", shoppingCart.SentTimesPointPromotionName, shoppingCart.TimesPoint.ToString("F2"));
         this.hlkSentTimesPoint.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
         {
             shoppingCart.SentTimesPointPromotionId
         });
     }
 }
コード例 #24
0
        /// <param name="format">Format to be used</param>
        /// <returns>Result</returns>
        /// <exception cref="EDPSymbologyException">A server side error occurred.</exception>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async System.Threading.Tasks.Task <Symbology> GetConvertAsync(string universe, System.Collections.Generic.IEnumerable <FieldEnum> to, Format?format, System.Threading.CancellationToken cancellationToken)
        {
            if (universe == null)
            {
                throw new System.ArgumentNullException("universe");
            }


            var urlBuilder_ = new System.Text.StringBuilder();

            urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/convert?");
            urlBuilder_.Append("universe=").Append(System.Uri.EscapeDataString(ConvertToString(universe, System.Globalization.CultureInfo.InvariantCulture))).Append("&");

            if (to != null && to.Count() > 0)
            {
                urlBuilder_.Append("to=");
                foreach (var item_ in to)
                {
                    urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(item_, System.Globalization.CultureInfo.InvariantCulture)));
                    if (item_ != to.Last())
                    {
                        urlBuilder_.Append(",");
                    }
                    else
                    {
                        urlBuilder_.Append("&");
                    }
                }
            }
            if (format != null)
            {
                urlBuilder_.Append("format=").Append(System.Uri.EscapeDataString(ConvertToString(format, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
            }
            urlBuilder_.Length--;

            var client_ = _httpClient;

            try
            {
                using (var request_ = new System.Net.Http.HttpRequestMessage())
                {
                    request_.Method = new System.Net.Http.HttpMethod("GET");
                    request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

                    PrepareRequest(client_, request_, urlBuilder_);
                    var url_ = urlBuilder_.ToString();
                    request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
                    PrepareRequest(client_, request_, url_);

                    var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

                    try
                    {
                        var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
                        if (response_.Content != null && response_.Content.Headers != null)
                        {
                            foreach (var item_ in response_.Content.Headers)
                            {
                                headers_[item_.Key] = item_.Value;
                            }
                        }

                        ProcessResponse(client_, response_);

                        var status_ = ((int)response_.StatusCode).ToString();
                        if (status_ == "200")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            var result_ = default(Symbology);
                            try
                            {
                                result_ = Newtonsoft.Json.JsonConvert.DeserializeObject <Symbology>(responseData_, _settings.Value);
                                return(result_);
                            }
                            catch (System.Exception exception_)
                            {
                                throw new EDPSymbologyException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_);
                            }
                        }
                        else
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            var result_ = default(Error);
                            try
                            {
                                result_ = Newtonsoft.Json.JsonConvert.DeserializeObject <Error>(responseData_, _settings.Value);
                            }
                            catch (System.Exception exception_)
                            {
                                throw new EDPSymbologyException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_);
                            }
                            throw new EDPSymbologyException <Error>("Error", (int)response_.StatusCode, responseData_, headers_, result_, null);
                        }
                    }
                    finally
                    {
                        if (response_ != null)
                        {
                            response_.Dispose();
                        }
                    }
                }
            }
            finally
            {
            }
        }
コード例 #25
0
        private ErrCode InitFromXML(string pathFile)
        {
            XDocument xDocument = new XDocument();
            ErrCode   result;

            try
            {
                xDocument = XDocument.Load(pathFile);
            }
            catch (System.IO.FileNotFoundException var_1_12)
            {
                this.ErrCodeParse(ErrCode.initFileNotFound);
                result = ErrCode.initFileNotFound;
                return(result);
            }
            catch (XmlException var_2_24)
            {
                this.ErrCodeParse(ErrCode.initFileIncorrect);
                result = ErrCode.initFileIncorrect;
                return(result);
            }
            string text  = "";
            string text2 = "";

            try
            {
                System.Collections.Generic.IEnumerable <XElement> enumerable = xDocument.Descendants("Item");
                if (enumerable.Count <XElement>() == 0)
                {
                    result = ErrCode.initFileIncorrect;
                    return(result);
                }
                foreach (XElement current in enumerable)
                {
                    text  = current.Element("Name").Value;
                    text2 = current.Element("Addr").Value;
                    string text3 = current.Element("TypeRW").Value.ToLower();
                    if (text3 == "read")
                    {
                        this._resultData.AddrRead.Add(text, text2);
                        this._resultData.NameRead.Add(text2, text);
                        this._resultData.ValueRead.Add(text2, new object());
                    }
                    else
                    {
                        if (!(text3 == "write"))
                        {
                            this._errTypeRW = text3;
                            this.ErrCodeParse(ErrCode.xmlTypeRWFlt);
                            result = ErrCode.xmlTypeRWFlt;
                            return(result);
                        }
                        this._resultData.AddrWrite.Add(text, text2);
                        this._resultData.NameWrite.Add(text2, text);
                    }
                }
            }
            catch (System.NullReferenceException var_8_1B7)
            {
                this.ErrCodeParse(ErrCode.xmlNoElement);
                result = ErrCode.xmlNoElement;
                return(result);
            }
            catch (System.ArgumentException var_9_1C9)
            {
                this._errItemName = text;
                this._errItemAddr = text2;
                this.ErrCodeParse(ErrCode.sameNameOrAddr);
                result = ErrCode.sameNameOrAddr;
                return(result);
            }
            this.CreateItemsRead();
            this.CreateItemsWrite();
            result = ErrCode.ok;
            return(result);
        }
コード例 #26
0
        public void RemoveByXml(XDocument xDoc, out int err)
        {
            ErrCode errCode = this.CheckXmlForRemoteItem(xDoc);

            if (errCode != ErrCode.ok)
            {
                err = (int)errCode;
            }
            else if (!this._client.GetConnectionState())
            {
                this.ErrCodeParse(ErrCode.serverConnFlt);
                err = 4;
            }
            else
            {
                System.Collections.Generic.IEnumerable <XElement> enumerable = xDoc.Descendants("Item");
                System.Collections.Generic.List <string>          list       = new System.Collections.Generic.List <string>(enumerable.Count <XElement>());
                System.Collections.Generic.List <string>          list2      = new System.Collections.Generic.List <string>(enumerable.Count <XElement>());
                foreach (XElement current in enumerable)
                {
                    string value  = current.Element("Name").Value;
                    string value2 = current.Element("Addr").Value;
                    string a      = current.Element("TypeRW").Value.ToLower();
                    if (a == "read")
                    {
                        this._items.AddrRead.Remove(value);
                        this._items.NameRead.Remove(value2);
                        this._items.ValueRead.Remove(value2);
                        list.Add(value2);
                    }
                    if (a == "write")
                    {
                        this._items.AddrWrite.Remove(value);
                        this._items.NameWrite.Remove(value2);
                        list2.Add(value2);
                    }
                }
                this.RefreshOpcItemsRead(list.ToArray <string>(), 2);
                this.RefreshOpcItemsWrite(list2.ToArray <string>(), 2);
                err = 0;
            }
        }
コード例 #27
0
 public void CheckInputData(XDocument xDoc, out int err)
 {
     if (!this._isServerTransData)
     {
         this.ErrCodeParse(ErrCode.serverConnFlt, "CheckInputData");
         err = 4;
     }
     else
     {
         System.Collections.Generic.IEnumerable <XElement> enumerable = xDoc.Descendants("Item");
         System.Collections.Generic.List <string>          list       = new System.Collections.Generic.List <string>(enumerable.Count <XElement>());
         System.Collections.Generic.List <string>          list2      = new System.Collections.Generic.List <string>(enumerable.Count <XElement>());
         try
         {
             foreach (XContainer current in enumerable)
             {
                 string value  = current.Element("Name").Value;
                 string value2 = current.Element("Addr").Value;
                 string a      = current.Element("TypeRW").Value.ToLower();
                 if (a == "read")
                 {
                     list.Add(value2);
                 }
                 if (a == "write")
                 {
                     list2.Add(value2);
                 }
             }
         }
         catch (System.ArgumentException var_7_128)
         {
             this.ErrCodeParse(ErrCode.xmlNoElement, "CheckInputData");
             err = 12;
             return;
         }
         ErrCode errCode = this.CheckDataRead(list.ToArray <string>());
         if (errCode != ErrCode.ok)
         {
             this.ErrCodeParse(errCode, "CheckInputData");
             err = (int)errCode;
         }
         else
         {
             ErrCode errCode2 = this.CheckDataWrite(list2.ToArray <string>());
             if (errCode2 != ErrCode.ok)
             {
                 this.ErrCodeParse(errCode2, "CheckInputData");
                 err = (int)errCode2;
             }
             else
             {
                 err = 0;
             }
         }
     }
 }
コード例 #28
0
 protected void btnSend_Click(object sender, System.EventArgs e)
 {
     System.Collections.Generic.IList <string>              userList   = this.GetUserList();
     System.Collections.Generic.IEnumerable <string>        enumerable = userList.Distinct <string>();
     System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
     if (enumerable.Count <string>() > 0)
     {
         System.Collections.Generic.List <Mail> list = new System.Collections.Generic.List <Mail>();
         string value = string.Empty;
         int    num   = 0;
         foreach (string current in enumerable)
         {
             value = System.Guid.NewGuid().ToString();
             dictionary.Add(current, value);
             string toMailId = System.Guid.NewGuid().ToString();
             list.Add(new Mail
             {
                 MailId        = value,
                 ToMailId      = toMailId,
                 MailName      = this.txtName.Text.Trim(),
                 MailFrom      = base.UserCode,
                 MailTo        = current,
                 AllMailToCode = this.hfldTo.Value,
                 AllMailTo     = this.txtTo.Text,
                 AllCopytoCode = this.hfldCopyto.Value,
                 AllCopyto     = this.txtCopyto.Text,
                 MailContent   = this.txtContent.Value,
                 IsValid       = true,
                 IsReaded      = false,
                 MailType      = "I",
                 AnnexId       = (string)this.ViewState["annexId"],
                 InputDate     = System.DateTime.Now.AddSeconds((double)num)
             });
             list.Add(new Mail
             {
                 MailId        = System.Guid.NewGuid().ToString(),
                 ToMailId      = toMailId,
                 MailName      = this.txtName.Text.Trim(),
                 MailFrom      = base.UserCode,
                 MailTo        = current,
                 AllMailToCode = this.hfldTo.Value,
                 AllMailTo     = this.txtTo.Text,
                 AllCopytoCode = this.hfldCopyto.Value,
                 AllCopyto     = this.txtCopyto.Text,
                 MailContent   = this.txtContent.Value,
                 IsValid       = true,
                 IsReaded      = false,
                 MailType      = "O",
                 AnnexId       = (string)this.ViewState["annexId"],
                 InputDate     = System.DateTime.Now.AddSeconds((double)num)
             });
             num++;
         }
         if (!string.IsNullOrEmpty(this.mailId) && this.edit == "1")
         {
             this.mailService.Delete(this.mailId);
         }
         this.mailService.AddOrUpdate(list);
         if (this.chkMobileMsg.Checked)
         {
             this.SendMobileMsg();
         }
         if (this.chkDbsj.Checked)
         {
             this.SendDbsj(dictionary);
         }
         this.hfldMailId.Value = value;
         base.RegisterScript("selectSend();");
         return;
     }
     base.RegisterScript("alert('收件人不能为空!');");
 }
コード例 #29
0
    private void PushDataToClient()
    {
        using (var context = new WebsiteTTKEntities())
        {
            //Get Category data
            System.Collections.Generic.IEnumerable<procategory> listOfCategories = (from s in context.procategories.AsEnumerable() where s.is_publish == true && s.is_menu == true
                                                      select new procategory
                                                      {
                                                          category_id = s.category_id,
                                                          category_name = s.category_name,
                                                          category_description = s.category_description,
                                                          category_images = s.category_images,
                                                          category_url = s.category_url,
                                                          create_date = s.create_date,
                                                          parent_id = s.parent_id,
                                                          is_publish = s.is_publish,
                                                          is_menu = s.is_menu,
                                                          is_label = s.is_label,
                                                          is_collection = s.is_collection
                                                      }).ToList();

            string currentHostUrl = Helper.GetHostURL();
            string isActive = Helper.IsHomePage() ? " active" : "";
            string menuLiItems = "<li class='nav-item'><a href='" + currentHostUrl + "' class='nav-link" + isActive + "'>Home</a></li>";
            System.Collections.Generic.IEnumerable<procategory> grandFatherCategories = (from t in listOfCategories where t.parent_id == 0 select t).ToList();
            foreach (var item in grandFatherCategories)
            {
                string grandfather_category_url = currentHostUrl + "/category.aspx?category_id=" + item.category_id;
                if (!String.IsNullOrEmpty(item.category_url))
                {
                    grandfather_category_url = item.category_url;
                }
                bool isLabel = item.is_label == null ? false : item.is_label.Value;
                isActive = Request.QueryString["category_id"] == item.category_id + "" ? " active" : "";
                System.Collections.Generic.IEnumerable<procategory> firstChildCategories = (from t in listOfCategories where t.parent_id == item.category_id select t).ToList();
                if (firstChildCategories.Count() > 0)
                {
                    if (isLabel)
                    {
                        menuLiItems += "<li class='nav-item dropdown menu-large'><span style='cursor: pointer;' data-toggle='dropdown' data-hover='dropdown' data-delay='200' class='dropdown-toggle nav-link" + isActive + "'>" + item.category_name + "<b class='caret'></b></span>";
                    }
                    else
                    {
                        menuLiItems += "<li class='nav-item dropdown menu-large'><a data-toggle='dropdown' data-hover='dropdown' data-delay='200' class='dropdown-toggle nav-link" + isActive + "' href='" + grandfather_category_url + "'>" + item.category_name + "<b class='caret'></b></a>";
                    }

                    menuLiItems += "<ul class='dropdown-menu megamenu'><li><div class='row'>";
                    foreach (var firstChild in firstChildCategories)
                    {
                        var father_category_url = currentHostUrl + "/category.aspx?category_id=" + firstChild.category_id;
                        if (!String.IsNullOrEmpty(firstChild.category_url))
                        {
                            father_category_url = firstChild.category_url;
                        }
                        isLabel = firstChild.is_label == null ? false : firstChild.is_label.Value;
                        isActive = Request.QueryString["category_id"] == firstChild.category_id + "" ? " active" : "";

                        System.Collections.Generic.IEnumerable<procategory> secondChildCategories = (from t in listOfCategories where t.parent_id == firstChild.category_id select t).ToList();
                        if (secondChildCategories.Count() > 0)
                        {
                            if (isLabel)
                            {
                                menuLiItems += "<div class='col-md-6 col-lg-3'><h5><span style='cursor: pointer;' class='nav-link" + isActive + "'>" + firstChild.category_name + "</span></h5>";
                            }
                            else
                            {
                                menuLiItems += "<div class='col-md-6 col-lg-3'><h5><a class='nav-link" + isActive + "' href='" + father_category_url + "'>" + firstChild.category_name + "</a></h5>";
                            }

                            menuLiItems += "<ul class='list-unstyled mb-3'>";
                            foreach (var secondChild in secondChildCategories)
                            {
                                var child_category_url = currentHostUrl + "/category.aspx?category_id=" + secondChild.category_id;
                                if (!String.IsNullOrEmpty(secondChild.category_url))
                                {
                                    child_category_url = secondChild.category_url;
                                }
                                isLabel = secondChild.is_label == null ? false : secondChild.is_label.Value;
                                isActive = Request.QueryString["category_id"] == secondChild.category_id + "" ? " active" : "";
                                if (isLabel)
                                {
                                    menuLiItems += "<li class='nav-item'><span style='cursor: pointer;' class='nav-link" + isActive + "'>" + secondChild.category_name + "</span></li>";
                                } else
                                {
                                    menuLiItems += "<li class='nav-item'><a href='" + child_category_url + "' class='nav-link" + isActive + "'>" + secondChild.category_name + "</a></li>";
                                }
                            }
                            menuLiItems += "</ul>";
                        } else
                        {
                            if (isLabel)
                            {
                                menuLiItems += "<div class='nav-item' style='margin-right: 35px;'><span class='nav-link" + isActive + "'>" + firstChild.category_name  + "</span>";
                            }
                            else
                            {
                                menuLiItems += "<div class='nav-item' style='margin-right: 35px;'><a class='nav-link" + isActive + "' href='" + father_category_url + "'>" + firstChild.category_name + "</a>";
                            }
                        }
                        menuLiItems += "</div>";
                    }
                    menuLiItems += "</div></li></ul>";
                } else
                {
                    if (isLabel)
                    {
                        menuLiItems += "<li class='nav-item'><span style='cursor: pointer;' class='nav-link" + isActive + "'>" + item.category_name + "</span>";
                    }
                    else
                    {
                        menuLiItems += "<li class='nav-item'><a class='nav-link" + isActive + "' href='" + grandfather_category_url + "'>" + item.category_name + "</a>";
                    }
                }
                menuLiItems += "</li>";
            }
            Mega_Menu_UL.InnerHtml = menuLiItems;
        }
    }
コード例 #30
0
        private void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.pnlNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
                return;
            }
            this.pnlShopCart.Visible  = true;
            this.pnlNoProduct.Visible = false;
            if (shoppingCart.LineItems.Count > 0)
            {
                decimal tax = shoppingCart.CalTotalTax();
                if (tax <= 50)
                {
                    this.lblTax.Text = string.Format("商品关税:<span style='text-decoration: line-through;'>{0}</span>", tax.ToString("F2"));
                }
                else
                {
                    this.lblTax.Text = string.Format("商品关税:{0}", tax.ToString("F2"));
                }
                //this.lblTax.Text = string.Format("商品关税:{0}", tax <50 ? "0.00" : tax.ToString("F2"));
                //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems)
                //{
                //    item.TaxRate = Math.Round(item.TaxRate * 100, 0);
                //}

                decimal activityReduct = shoppingCart.GetActivityPrice();
                this.lblReducedActivity.Text = string.Format("活动优惠:{0}", activityReduct == 0 ? "0.00" : activityReduct.ToString("F2"));

                this.lblTotalPrice.Money = shoppingCart.GetNewTotalIncludeTax();

                var query = from q in shoppingCart.LineItems
                            group q by new { id = q.SupplierId }
                into g
                    select new
                {
                    SupplierId     = g.FirstOrDefault().SupplierId,
                    SupplierName   = g.FirstOrDefault().SupplierName,
                    Logo           = g.FirstOrDefault().Logo,
                    ProductId      = g.FirstOrDefault().ProductId,
                    SkuId          = g.FirstOrDefault().SkuId,
                    Name           = g.FirstOrDefault().Name,
                    ThumbnailUrl60 = g.FirstOrDefault().ThumbnailUrl60,
                    TaxRate        = g.FirstOrDefault().TaxRate,
                    MemberPrice    = g.FirstOrDefault().MemberPrice,
                    Quantity       = g.FirstOrDefault().Quantity,
                    SKU            = g.FirstOrDefault().SKU,
                    ShippQuantity  = g.FirstOrDefault().ShippQuantity,
                    PromotionId    = g.FirstOrDefault().PromotionId,
                    PromotionName  = g.FirstOrDefault().PromotionName,
                    SubNewTotal    = g.FirstOrDefault().SubNewTotal,
                    NewTaxRate     = GetNewTaxRate(g.FirstOrDefault().TaxRate, g.FirstOrDefault().MinTaxRate, g.FirstOrDefault().MaxTaxRate)
                                     //itemInfo  = g.FirstOrDefault()
                };
                this.shoppingCartProductList.DataSource = query;
                this.shoppingCartProductList.DataBind();
                this.shoppingCartProductList.ShowProductCart();
            }
            if (shoppingCart.LineGifts.Count > 0)
            {
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 0
                    select s;
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 5
                    select s;
                this.shoppingCartGiftList.DataSource     = enumerable;
                this.shoppingCartGiftList.FreeDataSource = enumerable2;
                this.shoppingCartGiftList.DataBind();
                this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
            }
            if (shoppingCart.IsSendGift)
            {
                int num = 1;
                int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift);
                System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts();
                if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0)
                {
                    this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts;
                    this.shoppingCartPromoGiftList.DataBind();
                    this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num);
                }
            }

            //if (shoppingCart.IsReduced)
            //{
            this.lblAmoutPrice.Text       = string.Format("商品金额:{0}", shoppingCart.GetNewAmount().ToString("F2"));
            this.hlkReducedPromotion.Text = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
            if (shoppingCart.ReducedPromotionId != 0)
            {
                this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
                {
                    shoppingCart.ReducedPromotionId
                });
            }
            //}

            HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"];

            if (cookieSkuIds != null)
            {
                //cookieSkuIds.Expires = DateTime.Now.AddDays(-1);
                this.Page.Response.AppendCookie(cookieSkuIds);
            }
        }