Example #1
0
 private static Meeting?GetMeetingDataForTodayInternal(IEnumerable <Meeting>?meetingData)
 {
     return(meetingData?.FirstOrDefault(x => x.Date.Date.Equals(DateUtils.GetMondayOfThisWeek())));
 }
Example #2
0
        void UpdateDateLbl(string text)
        {
            string sizeCategory = UIApplication.SharedApplication.PreferredContentSizeCategory;

            StyleUtil.InitMonospacedLabel(DateLbl, StyleUtil.FontType.FontMonospaced, DateUtils.ReplaceAndInsertNewlineiOS(text, sizeCategory), 1.28, 12, 18);
        }
Example #3
0
        public void compute(DateTime startDate, DateTime endDate)
        {
            var tradedays  = dateRepo.GetStockTransactionDate(startDate, endDate);
            var parameters = startDate.ToShortDateString() + '_' + endDate.ToShortDateString() + "frontNext";

            if (!ExistInSqlServer(code, parameters))
            {
                CreateDBOrTableIfNecessary(code, parameters);
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("tdatetime", typeof(DateTime));
            dt.Columns.Add("future1");
            dt.Columns.Add("future2");
            dt.Columns.Add("expiredate1", typeof(DateTime));
            dt.Columns.Add("expiredate2", typeof(DateTime));
            dt.Columns.Add("duration1");
            dt.Columns.Add("duration2");
            dt.Columns.Add("indexPrice");
            dt.Columns.Add("price1");
            dt.Columns.Add("price2");
            dt.Columns.Add("basis1");
            dt.Columns.Add("basis2");
            dt.Columns.Add("basis12");

            foreach (var date in tradedays)
            {
                //var list = getSpecialFutureList(date);
                var list          = getFutureList(date);
                var index         = stockMinutelyRepo.GetStockTransaction(indexCode, date, date);
                var dataList      = new Dictionary <string, List <StockTransaction> >();
                var basisDataList = new List <specialBasis>();
                foreach (var item in list)
                {
                    var data = stockMinutelyRepo.GetStockTransaction(item.Key, date, date);
                    dataList.Add(item.Key, data);
                }
                for (int i = 5; i <= 235; i = i + 5)
                {
                    var data0    = new specialBasis();
                    var indexNow = index[i];
                    var future1  = dataList[list.Keys.First()][i];
                    var future2  = dataList[list.Keys.Last()][i];
                    data0.future1     = future1.Code;
                    data0.future2     = future2.Code;
                    data0.time        = indexNow.DateTime;
                    data0.expireDate1 = list[list.Keys.First()].expireDate;
                    data0.expireDate2 = list[list.Keys.Last()].expireDate;
                    data0.indexPrice  = indexNow.Close;
                    data0.price1      = future1.Volume == 0?future1.Close: (future1.Amount / future1.Volume) / 200;
                    data0.price2      = future2.Volume == 0?future2.Close: (future2.Amount / future2.Volume) / 200;
                    data0.basis1      = data0.price1 - data0.indexPrice;
                    data0.basis2      = data0.price2 - data0.indexPrice;
                    data0.basis12     = data0.price2 - data0.price1;
                    data0.duration1   = DateUtils.GetSpanOfTradeDays(date, data0.expireDate1) / 252.0;
                    data0.duration2   = DateUtils.GetSpanOfTradeDays(date, data0.expireDate2) / 252.0;
                    basisDataList.Add(data0);
                }
                foreach (var item in basisDataList)
                {
                    DataRow dr = dt.NewRow();
                    dr["tdatetime"]   = item.time;
                    dr["future1"]     = item.future1;
                    dr["future2"]     = item.future2;
                    dr["expireDate1"] = item.expireDate1;
                    dr["expireDate2"] = item.expireDate2;
                    dr["indexPrice"]  = item.indexPrice;
                    dr["price1"]      = item.price1;
                    dr["price2"]      = item.price2;
                    dr["basis1"]      = item.basis1;
                    dr["basis2"]      = item.basis2;
                    dr["basis12"]     = item.basis12;
                    dr["duration1"]   = item.duration1;
                    dr["duration2"]   = item.duration2;
                    dt.Rows.Add(dr);
                }
            }
            SaveResultToMssql(dt, code, parameters);
        }
        private ShoppingCartRuleResult checkSKULimitForCountry(MyHLShoppingCart myCart, ShoppingCartRuleResult Result)
        {
            Dictionary <string, List <SKULimitationInfo> > limits = SKULimitationProvider.GetSKULimitationInfo();

            if (limits != null)
            {
                if (limits.ContainsKey(Country))
                {
                    List <SKULimitationInfo> limitInfo = limits[Country];
                    foreach (var l in limitInfo)
                    {
                        if (limitInfo != null && limitInfo.Count > 0 && shouldApplyRules(l.StartDate, l.EndDate, l.LimitPeriodByDay))
                        {
                            if (myCart.CurrentItems == null)
                            {
                                return(Result);
                            }

                            string sku = myCart.CurrentItems[0].SKU.Trim();
                            if (l.SKU.Trim().Equals(sku))
                            {
                                _skuQuantityLimitPeriodByDay = l.LimitPeriodByDay;
                                _startDate = RecentOrdersHelper.ConvertDate(l.StartDate);
                                bool bSKUQtyOverLimit = false;

                                int SKUQtyBeingAdded = myCart.CurrentItems[0].Quantity;
                                if (SKUQtyBeingAdded > l.MaxQuantity)
                                {
                                    bSKUQtyOverLimit = true;
                                }

                                int qtyInCart = 0;
                                if (bSKUQtyOverLimit == false)
                                {
                                    if (myCart.CartItems != null && myCart.CartItems.Where(x => x.SKU == sku).Any()) // already in cart
                                    {
                                        qtyInCart = myCart.CartItems.Where(x => x.SKU == sku).Sum(x => x.Quantity);
                                        if ((qtyInCart + SKUQtyBeingAdded) > l.MaxQuantity)
                                        {
                                            bSKUQtyOverLimit = true;
                                        }
                                    }
                                }
                                if (bSKUQtyOverLimit == false)
                                {
                                    int numSkusOrders         = qtyInCart + SKUQtyBeingAdded; // what's in cart plus what's being added
                                    RecentOrdersHelper orders = getInternetOrders(myCart.DistributorID, this.Locale, DateUtils.GetCurrentLocalTime(this.Country));
                                    if (orders != null)
                                    {
                                        foreach (var o in orders.Orders)
                                        {
                                            foreach (var i in o.CartItems)
                                            {
                                                if (i.SKU == sku)
                                                {
                                                    numSkusOrders += i.Quantity;
                                                    //break;
                                                }
                                            }
                                        }
                                    }

                                    if (numSkusOrders > l.MaxQuantity)
                                    {
                                        bSKUQtyOverLimit = true;
                                    }
                                    //else
                                    //{
                                    //    if (myCart.CurrentItems[0].Quantity + numSkusOrders > l.MaxQuantity)
                                    //    {
                                    //        bSKUQtyOverLimit = true;
                                    //    }
                                    //}
                                }

                                if (bSKUQtyOverLimit == true)
                                {
                                    /// Your order of {0} exceeds the maximum quantity of {1} per member every {2} calendar days.
                                    Result.AddMessage(
                                        string.Format(
                                            HttpContext.GetGlobalResourceObject(
                                                string.Format("{0}_Rules", HLConfigManager.Platform),
                                                "SKULimitExceedByDay").ToString(),
                                            myCart.CurrentItems[0].SKU, l.MaxQuantity, l.LimitPeriodByDay));

                                    myCart.RuleResults.Add(Result);
                                    Result.Result = RulesResult.Failure;
                                }
                            }
                        }
                    }
                }
            }
            return(Result);
        }
Example #5
0
        public void Page_Load(object sender, EventArgs e)
        {
            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _adAreadId = Body.GetQueryInt("AdAreaID");
            if (Body.IsQueryExists("AdvID"))
            {
                _isEdit = true;
                _advId  = Body.GetQueryInt("AdvID");
            }

            if (!Page.IsPostBack)
            {
                var pageTitle = _isEdit ? "编辑广告" : "添加广告";
                BreadCrumb(AppManager.Cms.LeftMenu.IdFunction, AppManager.Cms.LeftMenu.Function.IdAdvertisement, pageTitle, AppManager.Cms.Permission.WebSite.Advertisement);

                ltlPageTitle.Text = pageTitle;

                StartDate.Text = DateUtils.GetDateAndTimeString(DateTime.Now);
                EndDate.Text   = DateUtils.GetDateAndTimeString(DateTime.Now.AddMonths(1));

                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                var nodeCount  = nodeIdList.Count;
                _isLastNodeArray = new bool[nodeCount];
                foreach (int theNodeID in nodeIdList)
                {
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, theNodeID);

                    var title    = WebUtils.GetChannelListBoxTitle(PublishmentSystemId, nodeInfo.NodeId, nodeInfo.NodeName, nodeInfo.NodeType, nodeInfo.ParentsCount, nodeInfo.IsLastNode, _isLastNodeArray);
                    var listitem = new ListItem(title, nodeInfo.NodeId.ToString());
                    NodeIDCollectionToChannel.Items.Add(listitem);
                    title = title + $"({nodeInfo.ContentNum})";
                    var listitem2 = new ListItem(title, nodeInfo.NodeId.ToString());
                    NodeIDCollectionToContent.Items.Add(listitem2);
                }

                var fileTemplateInfoArrayList = DataProvider.TemplateDao.GetTemplateInfoArrayListByType(PublishmentSystemId, ETemplateType.FileTemplate);
                if (fileTemplateInfoArrayList.Count > 0)
                {
                    foreach (TemplateInfo fileTemplateInfo in fileTemplateInfoArrayList)
                    {
                        var listitem = new ListItem(fileTemplateInfo.CreatedFileFullName, fileTemplateInfo.TemplateId.ToString());
                        FileTemplateIDCollection.Items.Add(listitem);
                    }
                }
                else
                {
                    FileTemplateIDCollectionRow.Visible = false;
                }

                EBooleanUtils.AddListItems(IsEnabled);
                ControlUtils.SelectListItems(IsEnabled, true.ToString());

                EAdvLevelTypeUtils.AddListItems(LevelType);
                ControlUtils.SelectListItems(LevelType, EAdvLevelTypeUtils.GetValue(EAdvLevelType.Hold));

                EAdvLevelUtils.AddListItems(Level);
                ControlUtils.SelectListItems(Level, EAdvLevelUtils.GetValue(EAdvLevel.Level1));

                EAdvWeightUtils.AddListItems(Weight);
                ControlUtils.SelectListItems(Weight, EAdvWeightUtils.GetValue(EAdvWeight.Level1));

                EAdvRotateTypeUtils.AddListItems(RotateType);
                ControlUtils.SelectListItems(RotateType, EAdvRotateTypeUtils.GetValue(EAdvRotateType.HandWeight));

                if (_isEdit)
                {
                    var advInfo = DataProvider.AdvDao.GetAdvInfo(_advId, PublishmentSystemId);
                    AdvName.Text            = advInfo.AdvName;
                    IsEnabled.SelectedValue = advInfo.IsEnabled.ToString();
                    IsDateLimited.Checked   = advInfo.IsDateLimited;
                    StartDate.Text          = DateUtils.GetDateAndTimeString(advInfo.StartDate);
                    EndDate.Text            = DateUtils.GetDateAndTimeString(advInfo.EndDate);
                    ControlUtils.SelectListItems(NodeIDCollectionToChannel, TranslateUtils.StringCollectionToStringList(advInfo.NodeIDCollectionToChannel));
                    ControlUtils.SelectListItems(NodeIDCollectionToContent, TranslateUtils.StringCollectionToStringList(advInfo.NodeIDCollectionToContent));
                    ControlUtils.SelectListItems(FileTemplateIDCollection, TranslateUtils.StringCollectionToStringList(advInfo.FileTemplateIDCollection));
                    LevelType.SelectedValue  = EAdvLevelTypeUtils.GetValue(advInfo.LevelType);
                    Level.SelectedValue      = advInfo.Level.ToString();
                    IsWeight.Checked         = advInfo.IsWeight;
                    Weight.SelectedValue     = advInfo.Weight.ToString();
                    RotateType.SelectedValue = EAdvRotateTypeUtils.GetValue(advInfo.RotateType);
                    RotateInterval.Text      = advInfo.RotateInterval.ToString();
                    Summary.Text             = advInfo.Summary;
                }

                ReFresh(null, EventArgs.Empty);
            }

            SuccessMessage(string.Empty);
        }
 private static long GetCurrentTime()
 {
     return(DateUtils.GetCurrentTime());
 }
Example #7
0
        internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            try
            {
                var entityName    = StlParserUtility.GetNameFromEntity(stlEntity);
                var channelIndex  = StlParserUtility.GetValueFromEntity(stlEntity);
                var attributeName = entityName.Substring(9, entityName.Length - 10);

                var upLevel   = 0;
                var topLevel  = -1;
                var channelId = contextInfo.ChannelId;
                if (!string.IsNullOrEmpty(channelIndex))
                {
                    //channelId = DataProvider.ChannelDao.GetIdByIndexName(pageInfo.SiteId, channelIndex);
                    channelId = Node.GetIdByIndexName(pageInfo.SiteId, channelIndex);
                    if (channelId == 0)
                    {
                        channelId = contextInfo.ChannelId;
                    }
                }

                if (attributeName.ToLower().StartsWith("up") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1)
                {
                    if (attributeName.ToLower().StartsWith("up."))
                    {
                        upLevel = 1;
                    }
                    else
                    {
                        var upLevelStr = attributeName.Substring(2, attributeName.IndexOf(".", StringComparison.Ordinal) - 2);
                        upLevel = TranslateUtils.ToInt(upLevelStr);
                    }
                    topLevel      = -1;
                    attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1);
                }
                else if (attributeName.ToLower().StartsWith("top") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1)
                {
                    if (attributeName.ToLower().StartsWith("top."))
                    {
                        topLevel = 1;
                    }
                    else
                    {
                        var topLevelStr = attributeName.Substring(3, attributeName.IndexOf(".", StringComparison.Ordinal) - 3);
                        topLevel = TranslateUtils.ToInt(topLevelStr);
                    }
                    upLevel       = 0;
                    attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1);
                }

                var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, channelId, upLevel, topLevel));

                if (StringUtils.EqualsIgnoreCase(ChannelId, attributeName))//栏目ID
                {
                    parsedContent = nodeInfo.Id.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(Title, attributeName) || StringUtils.EqualsIgnoreCase(ChannelName, attributeName))//栏目名称
                {
                    parsedContent = nodeInfo.ChannelName;
                }
                else if (StringUtils.EqualsIgnoreCase(ChannelIndex, attributeName))//栏目索引
                {
                    parsedContent = nodeInfo.IndexName;
                }
                else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//栏目正文
                {
                    parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, nodeInfo.Content, pageInfo.IsLocal);
                }
                else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//栏目链接地址
                {
                    parsedContent = PageUtility.GetChannelUrl(pageInfo.SiteInfo, nodeInfo, pageInfo.IsLocal);
                }
                else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//栏目图片地址
                {
                    parsedContent = nodeInfo.ImageUrl;

                    if (!string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//栏目添加日期
                {
                    parsedContent = DateUtils.Format(nodeInfo.AddDate, string.Empty);
                }
                else if (StringUtils.EqualsIgnoreCase(DirectoryName, attributeName))//生成文件夹名称
                {
                    parsedContent = PathUtils.GetDirectoryName(nodeInfo.FilePath, true);
                }
                else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//栏目组别
                {
                    parsedContent = nodeInfo.GroupNameCollection;
                }
                else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ChannelItem != null)
                {
                    parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ChannelItem.ItemIndex, attributeName, contextInfo).ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Keywords, attributeName))//栏目组别
                {
                    parsedContent = nodeInfo.Keywords;
                }
                else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Description, attributeName))//栏目组别
                {
                    parsedContent = nodeInfo.Description;
                }
                else
                {
                    //var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.Channel, DataProvider.ChannelDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, nodeInfo.ChannelId));
                    //parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, ETableStyle.Channel, styleInfo, string.Empty, null, string.Empty, true);

                    if (nodeInfo.Additional.Count > 0)
                    {
                        var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.ChannelDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, nodeInfo.Id));
                        // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008
                        if (styleInfo.Id > 0)
                        {
                            parsedContent = GetValue(attributeName, nodeInfo.Additional, false, styleInfo.DefaultValue);
                            if (!string.IsNullOrEmpty(parsedContent))
                            {
                                if (InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File))
                                {
                                    parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                                }
                                else
                                {
                                    parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, null, pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }

            return(parsedContent);
        }
Example #8
0
        /// <summary>
        /// Update the vCard with the dialog control values
        /// </summary>
        /// <param name="vCard">The vCard in which the settings are updated</param>
        public void GetValues(VCard vCard)
        {
            // Set the version based on the one selected
            vCard.Version = (cboVersion.SelectedIndex == 0) ? SpecificationVersions.vCard21 : SpecificationVersions.vCard30;

            // General properties.  Unique ID is not changed.  Last Revision is set to the current date and time.
            vCard.Classification.Value       = txtClass.Text;
            vCard.LastRevision.DateTimeValue = DateTime.Now;

            // Name properties
            vCard.Name.FamilyName      = txtLastName.Text;
            vCard.Name.GivenName       = txtFirstName.Text;
            vCard.Name.AdditionalNames = txtMiddleName.Text;
            vCard.Name.NamePrefix      = txtTitle.Text;
            vCard.Name.NameSuffix      = txtSuffix.Text;
            vCard.SortString.Value     = txtSortString.Text;
            vCard.FormattedName.Value  = txtFormattedName.Text;

            // We'll parse nicknames as a comma separated string
            vCard.Nickname.NicknamesString = txtNickname.Text;

            // For the collections, we'll clear the existing items and copy the modified items from the browse
            // control binding sources.

            // Addresses
            vCard.Addresses.Clear();
            vCard.Addresses.CloneRange((AddressPropertyCollection)ucAddresses.BindingSource.DataSource);

            // Labels
            vCard.Labels.Clear();
            vCard.Labels.CloneRange((LabelPropertyCollection)ucLabels.BindingSource.DataSource);

            // Phone/E-Mail
            vCard.Telephones.Clear();
            vCard.Telephones.CloneRange((TelephonePropertyCollection)ucPhones.BindingSource.DataSource);

            vCard.EMailAddresses.Clear();
            vCard.EMailAddresses.CloneRange((EMailPropertyCollection)ucEMail.BindingSource.DataSource);

            // Work
            vCard.Organization.Name = txtOrganization.Text;
            vCard.Title.Value       = txtJobTitle.Text;
            vCard.Role.Value        = txtRole.Text;

            // We'll parse units and categories as comma separated strings
            vCard.Organization.UnitsString    = txtUnits.Text;
            vCard.Categories.CategoriesString = txtCategories.Text;

            // Other
            if (!dtpBirthDate.Checked)
            {
                vCard.BirthDate.DateTimeValue = DateTime.MinValue;
            }
            else
            {
                vCard.BirthDate.DateTimeValue = dtpBirthDate.Value;

                // Store time too if it isn't midnight
                if (dtpBirthDate.Value != dtpBirthDate.Value.Date)
                {
                    vCard.BirthDate.ValueLocation = ValLocValue.DateTime;
                }
                else
                {
                    vCard.BirthDate.ValueLocation = ValLocValue.Date;
                }
            }

            // See if the new value is just an offset.  If so, set the value type to UTC Offset.
            try
            {
                if (txtTimeZone.Text.Trim().Length == 0)
                {
                    vCard.TimeZone.ValueLocation = ValLocValue.Text;
                    vCard.TimeZone.Value         = String.Empty;
                }
                else
                {
                    vCard.TimeZone.TimeSpanValue = DateUtils.FromISO8601TimeZone(
                        txtTimeZone.Text);
                    vCard.TimeZone.ValueLocation = ValLocValue.UtcOffset;
                }
            }
            catch
            {
                vCard.TimeZone.ValueLocation = ValLocValue.Text;
                vCard.TimeZone.Value         = txtTimeZone.Text;
            }

            if (txtLatitude.Text.Trim().Length != 0 || txtLongitude.Text.Trim().Length != 0)
            {
                vCard.GeographicPosition.Latitude  = Convert.ToDouble(txtLatitude.Text, CultureInfo.CurrentCulture);
                vCard.GeographicPosition.Longitude = Convert.ToDouble(txtLongitude.Text, CultureInfo.CurrentCulture);
            }
            else
            {
                vCard.GeographicPosition.Latitude = vCard.GeographicPosition.Longitude = 0.0F;
            }

            vCard.Url.Value = txtWebPage.Text;

            if (txtComments.Text.Length != 0)
            {
                if (vCard.Notes.Count != 0)
                {
                    vCard.Notes[0].Value = txtComments.Text;
                }
                else
                {
                    vCard.Notes.Add(txtComments.Text);
                }
            }
            else
            if (vCard.Notes.Count != 0)
            {
                vCard.Notes.RemoveAt(0);
            }

            // Photo
            if (ucPhoto.IsInline)
            {
                vCard.Photo.ValueLocation = ValLocValue.Binary;
                vCard.Photo.SetImageBytes(ucPhoto.GetImageBytes());
                vCard.Photo.ImageType = ucPhoto.ImageType;
            }
            else
            {
                vCard.Photo.ValueLocation = ValLocValue.Uri;
                vCard.Photo.Value         = ucPhoto.ImageFilename;
                vCard.Photo.ImageType     = ucPhoto.ImageType;
            }

            // Logo
            if (ucLogo.IsInline)
            {
                vCard.Logo.ValueLocation = ValLocValue.Binary;
                vCard.Logo.SetImageBytes(ucLogo.GetImageBytes());
                vCard.Logo.ImageType = ucLogo.ImageType;
            }
            else
            {
                vCard.Logo.ValueLocation = ValLocValue.Uri;
                vCard.Logo.Value         = ucLogo.ImageFilename;
                vCard.Logo.ImageType     = ucLogo.ImageType;
            }
        }
Example #9
0
        /// <summary>
        /// Load the data grid with all Easter Sunday dates for the specified range of years
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnEaster_Click(object sender, EventArgs e)
        {
            int    fromYear, toYear, year;
            string desc;

            EasterMethod em = EasterMethod.Gregorian;

            fromYear = (int)udcFromYear.Value;
            toYear   = (int)udcToYear.Value;

            if (rbJulian.Checked)
            {
                em = EasterMethod.Julian;
            }
            else
            if (rbOrthodox.Checked)
            {
                em = EasterMethod.Orthodox;
            }

            // Adjust years as necessary based on the method
            if (em != EasterMethod.Julian)
            {
                if (fromYear < 1583)
                {
                    fromYear = 1583;
                }

                if (fromYear > 4099)
                {
                    fromYear = 4099;
                }

                if (toYear < 1583)
                {
                    toYear = 1583;
                }

                if (toYear > 4099)
                {
                    toYear = 4099;
                }
            }
            else
            {
                if (fromYear < 326)
                {
                    fromYear = 326;
                }

                if (toYear < 326)
                {
                    toYear = 326;
                }
            }

            if (fromYear > toYear)
            {
                year     = fromYear;
                fromYear = toYear;
                toYear   = year;
            }

            udcFromYear.Value = fromYear;
            udcToYear.Value   = toYear;

            this.Cursor = Cursors.WaitCursor;

            // Create the grid view's data source
            List <ListItem> items = new List <ListItem>();

            desc = String.Format("Easter ({0})", em.ToString());

            while (fromYear <= toYear)
            {
                items.Add(new ListItem(DateUtils.EasterSunday(fromYear++, em), desc));
            }

            dgvDatesFound.DataSource = items;

            this.Cursor = Cursors.Default;
        }
Example #10
0
        public string GetList(int currentIndex, int rows)
        {
            if (CurrentUser.UserID > 0)
            {
                isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName);
            }
            isUnverifiedUser = !CurrentUser.IsSuperUser && CurrentUser.IsInRole("Unverified Users");

            var journalControllerInternal = InternalJournalController.Instance;
            var sb = new StringBuilder();

            string statusTemplate = Localization.GetString("journal_status", ResxPath);
            string linkTemplate   = Localization.GetString("journal_link", ResxPath);
            string photoTemplate  = Localization.GetString("journal_photo", ResxPath);
            string fileTemplate   = Localization.GetString("journal_file", ResxPath);

            statusTemplate = BaseUrlRegex.Replace(statusTemplate, url);
            linkTemplate   = BaseUrlRegex.Replace(linkTemplate, url);
            photoTemplate  = BaseUrlRegex.Replace(photoTemplate, url);
            fileTemplate   = BaseUrlRegex.Replace(fileTemplate, url);

            string comment = Localization.GetString("comment", ResxPath);

            IList <JournalItem> journalList;

            if (JournalId > 0)
            {
                var journal = JournalController.Instance.GetJournalItem(PortalSettings.PortalId, CurrentUser.UserID,
                                                                        JournalId, false, false, true);
                journalList = new List <JournalItem>();
                if (journal != null)
                {
                    journalList.Add(journal);
                }
            }
            else if (ProfileId > 0)
            {
                journalList = journalControllerInternal.GetJournalItemsByProfile(OwnerPortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows);
            }
            else if (SocialGroupId > 0)
            {
                journalList = journalControllerInternal.GetJournalItemsByGroup(OwnerPortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows);
            }
            else
            {
                journalList = journalControllerInternal.GetJournalItems(OwnerPortalId, ModuleId, CurrentUser.UserID, currentIndex, rows);
            }

            var journalIds = journalList.Select(ji => ji.JournalId).ToList();
            IList <CommentInfo> comments = JournalController.Instance.GetCommentsByJournalIds(journalIds);

            foreach (JournalItem ji in journalList)
            {
                string replacement = GetStringReplacement(ji);

                string rowTemplate;
                if (ji.JournalType == "status")
                {
                    rowTemplate = statusTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else if (ji.JournalType == "link")
                {
                    rowTemplate = linkTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else if (ji.JournalType == "photo")
                {
                    rowTemplate = photoTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else if (ji.JournalType == "file")
                {
                    rowTemplate = fileTemplate;
                    rowTemplate = TemplateRegex.Replace(rowTemplate, replacement);
                }
                else
                {
                    rowTemplate = GetJournalTemplate(ji.JournalType, ji);
                }

                var ctl = new JournalControl();

                bool isLiked = false;
                ctl.LikeList    = GetLikeListHTML(ji, ref isLiked);
                ctl.LikeLink    = String.Empty;
                ctl.CommentLink = String.Empty;

                ctl.AuthorNameLink = "<a href=\"" + Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + ji.JournalAuthor.Id }) + "\">" + ji.JournalAuthor.Name + "</a>";
                if (CurrentUser.UserID > 0 && !isUnverifiedUser)
                {
                    if (!ji.CommentsDisabled)
                    {
                        ctl.CommentLink = "<a href=\"#\" id=\"cmtbtn-" + ji.JournalId + "\">" + comment + "</a>";
                    }

                    if (isLiked)
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:unlike}</a>";
                    }
                    else
                    {
                        ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:like}</a>";
                    }
                }

                ctl.CommentArea = GetCommentAreaHTML(ji, comments);
                ji.TimeFrame    = DateUtils.CalculateDateForDisplay(ji.DateCreated);
                ji.DateCreated  = CurrentUser.LocalTime(ji.DateCreated);

                if (ji.Summary != null)
                {
                    ji.Summary = ji.Summary.Replace("\n", "<br />");
                }

                if (ji.Body != null)
                {
                    ji.Body = ji.Body.Replace(Environment.NewLine, "<br />");
                }

                var    tokenReplace = new JournalItemTokenReplace(ji, ctl);
                string tmp          = tokenReplace.ReplaceJournalItemTokens(rowTemplate);
                tmp = tmp.Replace("<br>", "<br />");
                sb.Append("<div class=\"journalrow\" id=\"jid-" + ji.JournalId + "\">");
                if (isAdmin || CurrentUser.UserID == ji.UserId || (ProfileId > Null.NullInteger && CurrentUser.UserID == ProfileId))
                {
                    sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>");
                }
                sb.Append(tmp);
                sb.Append("</div>");
            }

            return(Utilities.LocalizeControl(sb.ToString()));
        }
Example #11
0
        public async override Task <Resultats> CalculResult()
        {
            StopChrono();
            //calcul de l'age pour connaitre la marge de temps à rajouter au temps min
            var age          = DateUtils.IntervalleEntreDeuxDatesAnnee(ContextAppli.ContextUtilisateur.EnCoursUser.DateNaissance, DateUtils.GetMaintenant());
            var nbMilisecAge = (age < 30) ? 0 : (((age - 20) / 10) * 800);

            //calcul de l'interval de temps de résolution du jeu en fonction de l'age et de la diffculté
            var tempsMin = 0;
            var tempsMax = 0;

            if (Difficulte.Equals(DifficulteEnum.FACILE))
            {
                tempsMax = (25000 + nbMilisecAge + 650) * _nbTours;
                tempsMin = (5000 + nbMilisecAge + 650) * _nbTours;
            }

            if (Difficulte.Equals(DifficulteEnum.MOYEN))
            {
                tempsMax = (23000 + nbMilisecAge + 650) * _nbTours;
                tempsMin = (6000 + nbMilisecAge + 650) * _nbTours;
            }

            if (Difficulte.Equals(DifficulteEnum.DIFFICILE))
            {
                tempsMax = (20000 + nbMilisecAge + 650) * _nbTours;
                tempsMin = (6000 + nbMilisecAge + 650) * _nbTours;
            }

            //calcul de la note de temps
            int noteTemps;

            if (TempsPasse <= tempsMin)
            {
                noteTemps = 100;
            }
            else if (TempsPasse >= tempsMax)
            {
                noteTemps = 0;
            }
            else
            {
                noteTemps = 100 - ((TempsPasse - tempsMin) / ((tempsMax - tempsMin) / 100));
            }

            //prise en compte des erreurs
            var noteAvecErreurs = ((_nbTours - CompteurErreurs) * noteTemps) / _nbTours;

            //calcul de la note finale et sauvegarde
            return(await SaveResult(noteAvecErreurs));
        }
Example #12
0
        internal static string Parse(string stlEntity, PageInfo pageInfo)
        {
            var parsedContent = string.Empty;

            if (pageInfo?.UserInfo == null)
            {
                return(string.Empty);
            }

            try
            {
                var entityName    = StlParserUtility.GetNameFromEntity(stlEntity);
                var attributeName = entityName.Substring(6, entityName.Length - 7);

                if (StringUtils.EqualsIgnoreCase(Id, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Id.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(UserName, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.UserName;
                }
                else if (StringUtils.EqualsIgnoreCase(CreateDate, attributeName))
                {
                    parsedContent = DateUtils.Format(pageInfo.UserInfo.CreateDate, string.Empty);
                }
                else if (StringUtils.EqualsIgnoreCase(LastActivityDate, attributeName))
                {
                    parsedContent = DateUtils.Format(pageInfo.UserInfo.LastActivityDate, string.Empty);
                }
                else if (StringUtils.EqualsIgnoreCase(CountOfLogin, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.CountOfLogin.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(CountOfWriting, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.CountOfWriting.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(DisplayName, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.DisplayName;
                }
                else if (StringUtils.EqualsIgnoreCase(Email, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Email;
                }
                else if (StringUtils.EqualsIgnoreCase(Mobile, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Mobile;
                }
                else if (StringUtils.EqualsIgnoreCase(AvatarUrl, attributeName))
                {
                    parsedContent = PageUtility.GetUserAvatarUrl(pageInfo.ApiUrl, pageInfo.UserInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(Organization, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Organization;
                }
                else if (StringUtils.EqualsIgnoreCase(Department, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Department;
                }
                else if (StringUtils.EqualsIgnoreCase(Position, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Position;
                }
                else if (StringUtils.EqualsIgnoreCase(Gender, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Gender;
                }
                else if (StringUtils.EqualsIgnoreCase(Birthday, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Birthday;
                }
                else if (StringUtils.EqualsIgnoreCase(Education, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Education;
                }
                else if (StringUtils.EqualsIgnoreCase(Graduation, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Graduation;
                }
                else if (StringUtils.EqualsIgnoreCase(Address, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Address;
                }
                else if (StringUtils.EqualsIgnoreCase(WeiXin, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.WeiXin;
                }
                else if (StringUtils.EqualsIgnoreCase(Qq, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Qq;
                }
                else if (StringUtils.EqualsIgnoreCase(WeiBo, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.WeiBo;
                }
                else if (StringUtils.EqualsIgnoreCase(Interests, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Interests;
                }
                else if (StringUtils.EqualsIgnoreCase(Signature, attributeName))
                {
                    parsedContent = pageInfo.UserInfo.Signature;
                }
            }
            catch
            {
                // ignored
            }

            return(parsedContent);
        }
Example #13
0
        internal static bool TryParse(string text, ref int index, out Envelope envelope)
        {
            InternetAddressList from, sender, replyto, to, cc, bcc;
            string         inreplyto, messageid, subject, nstring;
            DateTimeOffset?date = null;

            envelope = null;

            while (index < text.Length && text[index] == ' ')
            {
                index++;
            }

            if (index >= text.Length || text[index] != '(')
            {
                if (index + 3 <= text.Length && text.Substring(index, 3) == "NIL")
                {
                    index += 3;
                    return(true);
                }

                return(false);
            }

            index++;

            if (!TryParse(text, ref index, out nstring))
            {
                return(false);
            }

            if (nstring != null)
            {
                DateTimeOffset value;

                if (!DateUtils.TryParse(nstring, out value))
                {
                    return(false);
                }

                date = value;
            }

            if (!TryParse(text, ref index, out subject))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out from))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out sender))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out replyto))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out to))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out cc))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out bcc))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out inreplyto))
            {
                return(false);
            }

            if (!TryParse(text, ref index, out messageid))
            {
                return(false);
            }

            if (index >= text.Length || text[index] != ')')
            {
                return(false);
            }

            index++;

            envelope = new Envelope {
                Date      = date,
                Subject   = subject,
                From      = from,
                Sender    = sender,
                ReplyTo   = replyto,
                To        = to,
                Cc        = cc,
                Bcc       = bcc,
                InReplyTo = inreplyto != null?MimeUtils.EnumerateReferences(inreplyto).FirstOrDefault() : null,
                                MessageId = messageid != null?MimeUtils.EnumerateReferences(messageid).FirstOrDefault() : null
            };

            return(true);
        }
Example #14
0
        internal void Encode(StringBuilder builder)
        {
            builder.Append('(');

            if (Date.HasValue)
            {
                builder.AppendFormat("\"{0}\" ", DateUtils.FormatDate(Date.Value));
            }
            else
            {
                builder.Append("NIL ");
            }

            if (Subject != null)
            {
                builder.AppendFormat("{0} ", MimeUtils.Quote(Subject));
            }
            else
            {
                builder.Append("NIL ");
            }

            if (From.Count > 0)
            {
                EncodeAddressList(builder, From);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (Sender.Count > 0)
            {
                EncodeAddressList(builder, Sender);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (ReplyTo.Count > 0)
            {
                EncodeAddressList(builder, ReplyTo);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (To.Count > 0)
            {
                EncodeAddressList(builder, To);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (Cc.Count > 0)
            {
                EncodeAddressList(builder, Cc);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (Bcc.Count > 0)
            {
                EncodeAddressList(builder, Bcc);
                builder.Append(' ');
            }
            else
            {
                builder.Append("NIL ");
            }

            if (InReplyTo != null)
            {
                builder.AppendFormat("{0} ", MimeUtils.Quote(InReplyTo));
            }
            else
            {
                builder.Append("NIL ");
            }

            if (MessageId != null)
            {
                builder.AppendFormat("{0}", MimeUtils.Quote(MessageId));
            }
            else
            {
                builder.Append("NIL");
            }

            builder.Append(')');
        }
Example #15
0
        public async Task <string> GetWhereStringByStlSearchAsync(IDatabaseManager databaseManager, bool isAllSites, string siteName, string siteDir, string siteIds, string channelIndex, string channelName, string channelIds, string type, string word, string dateAttribute, string dateFrom, string dateTo, string since, int siteId, List <string> excludeAttributes, NameValueCollection form)
        {
            var whereBuilder = new StringBuilder();

            Site site = null;

            if (!string.IsNullOrEmpty(siteName))
            {
                site = await _siteRepository.GetSiteBySiteNameAsync(siteName);
            }
            else if (!string.IsNullOrEmpty(siteDir))
            {
                site = await _siteRepository.GetSiteByDirectoryAsync(siteDir);
            }
            if (site == null)
            {
                site = await _siteRepository.GetAsync(siteId);
            }

            var channelId = await _channelRepository.GetChannelIdAsync(siteId, siteId, channelIndex, channelName);

            var channel = await _channelRepository.GetAsync(channelId);

            if (isAllSites)
            {
                whereBuilder.Append("(SiteId > 0) ");
            }
            else if (!string.IsNullOrEmpty(siteIds))
            {
                whereBuilder.Append($"(SiteId IN ({TranslateUtils.ToSqlInStringWithoutQuote(ListUtils.GetIntList(siteIds))})) ");
            }
            else
            {
                whereBuilder.Append($"(SiteId = {site.Id}) ");
            }

            if (!string.IsNullOrEmpty(channelIds))
            {
                whereBuilder.Append(" AND ");
                var channelIdList = new List <int>();
                foreach (var theChannelId in ListUtils.GetIntList(channelIds))
                {
                    var theChannel = await _channelRepository.GetAsync(theChannelId);

                    channelIdList.AddRange(
                        await _channelRepository.GetChannelIdsAsync(theChannel.SiteId, theChannel.Id, ScopeType.All));
                }
                whereBuilder.Append(channelIdList.Count == 1
                    ? $"(ChannelId = {channelIdList[0]}) "
                    : $"(ChannelId IN ({TranslateUtils.ToSqlInStringWithoutQuote(channelIdList)})) ");
            }
            else if (channelId != siteId)
            {
                whereBuilder.Append(" AND ");

                var channelIdList = await _channelRepository.GetChannelIdsAsync(siteId, channelId, ScopeType.All);

                whereBuilder.Append(channelIdList.Count == 1
                    ? $"(ChannelId = {channelIdList[0]}) "
                    : $"(ChannelId IN ({TranslateUtils.ToSqlInStringWithoutQuote(channelIdList)})) ");
            }

            var typeList = new List <string>();

            if (string.IsNullOrEmpty(type))
            {
                typeList.Add(nameof(Content.Title));
            }
            else
            {
                typeList = ListUtils.GetStringList(type);
            }

            if (!string.IsNullOrEmpty(word))
            {
                whereBuilder.Append(" AND (");
                foreach (var attributeName in typeList)
                {
                    whereBuilder.Append($"[{attributeName}] LIKE '%{AttackUtils.FilterSql(word)}%' OR ");
                }
                whereBuilder.Length = whereBuilder.Length - 3;
                whereBuilder.Append(")");
            }

            if (string.IsNullOrEmpty(dateAttribute))
            {
                dateAttribute = nameof(Content.AddDate);
            }

            if (!string.IsNullOrEmpty(dateFrom))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} >= {SqlUtils.GetComparableDate(_settingsManager.Database.DatabaseType, TranslateUtils.ToDateTime(dateFrom))} ");
            }
            if (!string.IsNullOrEmpty(dateTo))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} <= {SqlUtils.GetComparableDate(_settingsManager.Database.DatabaseType, TranslateUtils.ToDateTime(dateTo))} ");
            }
            if (!string.IsNullOrEmpty(since))
            {
                var sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since));
                whereBuilder.Append($" AND {dateAttribute} BETWEEN {SqlUtils.GetComparableDateTime(_settingsManager.Database.DatabaseType, sinceDate)} AND {SqlUtils.GetComparableNow(_settingsManager.Database.DatabaseType)} ");
            }

            var tableName = _channelRepository.GetTableName(site, channel);

            //var styleInfoList = RelatedIdentities.GetTableStyleInfoList(site, channel.Id);

            foreach (string key in form.Keys)
            {
                if (ListUtils.ContainsIgnoreCase(excludeAttributes, key))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(form[key]))
                {
                    continue;
                }

                var value = StringUtils.Trim(form[key]);
                if (string.IsNullOrEmpty(value))
                {
                    continue;
                }

                var columnInfo = await databaseManager.GetTableColumnInfoAsync(tableName, key);

                if (columnInfo != null && (columnInfo.DataType == DataType.VarChar || columnInfo.DataType == DataType.Text))
                {
                    whereBuilder.Append(" AND ");
                    whereBuilder.Append($"({key} LIKE '%{value}%')");
                }
                //else
                //{
                //    foreach (var tableStyleInfo in styleInfoList)
                //    {
                //        if (StringUtils.EqualsIgnoreCase(tableStyleInfo.AttributeName, key))
                //        {
                //            whereBuilder.Append(" AND ");
                //            whereBuilder.Append($"({ContentAttribute.SettingsXml} LIKE '%{key}={value}%')");
                //            break;
                //        }
                //    }
                //}
            }

            return(whereBuilder.ToString());
        }
Example #16
0
        public void TestChangeHeaders()
        {
            const string addressList1 = "\"Example 1\" <*****@*****.**>, \"Example 2\" <*****@*****.**>";
            const string addressList2 = "\"Example 3\" <*****@*****.**>, \"Example 4\" <*****@*****.**>";
            const string references1  = "<*****@*****.**> <*****@*****.**>";
            const string references2  = "<*****@*****.**> <*****@*****.**>";
            const string mailbox1     = "\"Example 1\" <*****@*****.**>";
            const string mailbox2     = "\"Example 2\" <*****@*****.**>";
            const string date1        = "Thu, 28 Jun 2007 12:47:52 -0500";
            const string date2        = "Fri, 29 Jun 2007 12:47:52 -0500";
            const string msgid1       = "*****@*****.**";
            const string msgid2       = "*****@*****.**";
            var          message      = new MimeMessage();

            foreach (var property in message.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                var            getter = property.GetGetMethod();
                var            setter = property.GetSetMethod();
                DateTimeOffset date;
                object         value;
                HeaderId       id;

                if (!Enum.TryParse(property.Name, out id))
                {
                    continue;
                }

                switch (property.PropertyType.FullName)
                {
                case "MimeKit.InternetAddressList":
                    message.Headers[id] = addressList1;

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(addressList1, value.ToString(), "Unexpected result when setting {0} to addressList1", property.Name);

                    message.Headers[message.Headers.IndexOf(id)] = new Header(id, addressList2);

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(addressList2, value.ToString(), "Unexpected result when setting {0} to addressList2", property.Name);
                    break;

                case "MimeKit.MailboxAddress":
                    message.Headers[id] = mailbox1;

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(mailbox1, value.ToString(), "Unexpected result when setting {0} to mailbox1", property.Name);

                    message.Headers[message.Headers.IndexOf(id)] = new Header(id, mailbox2);

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(mailbox2, value.ToString(), "Unexpected result when setting {0} to mailbox2", property.Name);

                    setter.Invoke(message, new object[] { null });
                    value = getter.Invoke(message, new object[0]);
                    Assert.IsNull(value, "Expected null value after setting {0} to null.", property.Name);
                    Assert.AreEqual(-1, message.Headers.IndexOf(id), "Expected {0} header to be removed after setting it to null.", property.Name);
                    break;

                case "MimeKit.MessageIdList":
                    message.Headers[id] = references1;

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(references1, value.ToString(), "Unexpected result when setting {0} to references1", property.Name);

                    message.Headers[message.Headers.IndexOf(id)] = new Header(id, references2);

                    value = getter.Invoke(message, new object[0]);
                    Assert.AreEqual(references2, value.ToString(), "Unexpected result when setting {0} to references2", property.Name);
                    break;

                case "System.DateTimeOffset":
                    message.Headers[id] = date1;

                    date = (DateTimeOffset)getter.Invoke(message, new object[0]);
                    Assert.AreEqual(date1, DateUtils.FormatDate(date), "Unexpected result when setting {0} to date1", property.Name);

                    message.Headers[message.Headers.IndexOf(id)] = new Header(id, date2);

                    date = (DateTimeOffset)getter.Invoke(message, new object[0]);
                    Assert.AreEqual(date2, DateUtils.FormatDate(date), "Unexpected result when setting {0} to date2", property.Name);
                    break;

                case "System.String":
                    switch (id)
                    {
                    case HeaderId.ResentMessageId:
                    case HeaderId.MessageId:
                    case HeaderId.InReplyTo:
                        message.Headers[id] = "<" + msgid1 + ">";

                        value = getter.Invoke(message, new object[0]);
                        Assert.AreEqual(msgid1, value.ToString(), "Unexpected result when setting {0} to msgid1", property.Name);

                        message.Headers[message.Headers.IndexOf(id)] = new Header(id, "<" + msgid2 + ">");

                        value = getter.Invoke(message, new object[0]);
                        Assert.AreEqual(msgid2, value.ToString(), "Unexpected result when setting {0} to msgid2", property.Name);

                        setter.Invoke(message, new object[] { "<" + msgid1 + ">" });
                        value = getter.Invoke(message, new object[0]);
                        Assert.AreEqual(msgid1, value.ToString(), "Unexpected result when setting {0} to msgid1 via the setter.", property.Name);

                        if (id == HeaderId.InReplyTo)
                        {
                            setter.Invoke(message, new object[] { null });
                            value = getter.Invoke(message, new object[0]);
                            Assert.IsNull(value, "Expected null value after setting {0} to null.", property.Name);
                            Assert.AreEqual(-1, message.Headers.IndexOf(id), "Expected {0} header to be removed after setting it to null.", property.Name);
                        }
                        break;

                    case HeaderId.Subject:
                        message.Headers[id] = "Subject #1";

                        value = getter.Invoke(message, new object[0]);
                        Assert.AreEqual("Subject #1", value.ToString(), "Unexpected result when setting {0} to subject1", property.Name);

                        message.Headers[message.Headers.IndexOf(id)] = new Header(id, "Subject #2");

                        value = getter.Invoke(message, new object[0]);
                        Assert.AreEqual("Subject #2", value.ToString(), "Unexpected result when setting {0} to msgid2", property.Name);
                        break;
                    }
                    break;
                }
            }
        }
        public ActionResult Create(CreatePrivateMessageViewModel createPrivateMessageViewModel)
        {
            if (!SettingsService.GetSettings().EnablePrivateMessages || LoggedOnUser.DisablePrivateMessages == true)
            {
                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
            }
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                if (ModelState.IsValid)
                {
                    // Check flood control
                    var lastMessage = _privateMessageService.GetLastSentPrivateMessage(LoggedOnUser.Id);
                    if (lastMessage != null && DateUtils.TimeDifferenceInMinutes(DateTime.UtcNow, lastMessage.DateSent) < SettingsService.GetSettings().PrivateMessageFloodControl)
                    {
                        throw new Exception(LocalizationService.GetResourceString("PM.SendingToQuickly"));
                    }

                    var memberTo = MembershipService.GetUser(createPrivateMessageViewModel.To);

                    // first check they are not trying to message themself!
                    if (memberTo != null)
                    {
                        // Map the view model to message
                        var privateMessage = new PrivateMessage
                        {
                            UserFrom = LoggedOnUser,
                            Message  = createPrivateMessageViewModel.Message,
                        };

                        // check the member
                        if (!String.Equals(memberTo.UserName, LoggedOnUser.UserName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            // Check in box size for both
                            var receiverCount = _privateMessageService.GetAllReceivedByUser(memberTo.Id).Count;
                            if (receiverCount > SettingsService.GetSettings().MaxPrivateMessagesPerMember)
                            {
                                throw new Exception(string.Format(LocalizationService.GetResourceString("PM.ReceivedItemsOverCapcity"), memberTo.UserName));
                            }

                            // If the receiver is about to go over the allowance them let then know too
                            if (receiverCount > (SettingsService.GetSettings().MaxPrivateMessagesPerMember - SiteConstants.PrivateMessageWarningAmountLessThanAllowedSize))
                            {
                                // Send user a warning they are about to exceed
                                var sb = new StringBuilder();
                                sb.AppendFormat("<p>{0}</p>", LocalizationService.GetResourceString("PM.AboutToExceedInboxSizeBody"));
                                var email = new Email
                                {
                                    EmailTo = memberTo.Email,
                                    NameTo  = memberTo.UserName,
                                    Subject = LocalizationService.GetResourceString("PM.AboutToExceedInboxSizeSubject")
                                };
                                email.Body = _emailService.EmailTemplate(email.NameTo, sb.ToString());
                                _emailService.SendMail(email);
                            }

                            // Good to go send the message!
                            privateMessage.UserTo = memberTo;
                            _privateMessageService.Add(privateMessage);

                            try
                            {
                                // Finally send an email to the user so they know they have a new private message
                                // As long as they have not had notifications disabled
                                if (memberTo.DisableEmailNotifications != true)
                                {
                                    var email = new Email
                                    {
                                        EmailTo = memberTo.Email,
                                        Subject = LocalizationService.GetResourceString("PM.NewPrivateMessageSubject"),
                                        NameTo  = memberTo.UserName
                                    };

                                    var sb = new StringBuilder();
                                    sb.AppendFormat("<p>{0}</p>", string.Format(LocalizationService.GetResourceString("PM.NewPrivateMessageBody"), LoggedOnUser.UserName));
                                    email.Body = _emailService.EmailTemplate(email.NameTo, sb.ToString());
                                    _emailService.SendMail(email);
                                }

                                unitOfWork.Commit();

                                return(PartialView("_PrivateMessage", privateMessage));
                            }
                            catch (Exception ex)
                            {
                                unitOfWork.Rollback();
                                LoggingService.Error(ex);
                                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
                            }
                        }
                        else
                        {
                            throw new Exception(LocalizationService.GetResourceString("PM.TalkToSelf"));
                        }
                    }
                    else
                    {
                        // Error send back to user
                        throw new Exception(LocalizationService.GetResourceString("PM.UnableFindMember"));
                    }
                }
                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
            }
        }
        public void GenerateTimestampTest()
        {
            var result = DateUtils.GenerateTimestamp();

            Assert.IsNotNull(result);
        }
Example #19
0
        private void ProcessRoleGroups(ExportImportJob importJob, ImportDto importDto,
                                       IEnumerable <ExportRoleGroup> otherRoleGroups)
        {
            var changedGroups   = new List <RoleGroupItem>();
            var portalId        = importJob.PortalId;
            var localRoleGroups = CBO.FillCollection <ExportRoleGroup>(DataProvider.Instance().GetAllRoleGroups(portalId, DateUtils.GetDatabaseUtcTime().AddYears(1), null));

            foreach (var other in otherRoleGroups)
            {
                if (CheckCancelled(importJob))
                {
                    return;
                }
                var createdBy  = Util.GetUserIdByName(importJob, other.CreatedByUserID, other.CreatedByUserName);
                var modifiedBy = Util.GetUserIdByName(importJob, other.LastModifiedByUserID, other.LastModifiedByUserName);
                var local      = localRoleGroups.FirstOrDefault(t => t.RoleGroupName == other.RoleGroupName);

                if (local != null)
                {
                    other.LocalId = local.RoleGroupID;
                    switch (importDto.CollisionResolution)
                    {
                    case CollisionResolution.Ignore:
                        Result.AddLogEntry("Ignored role group", other.RoleGroupName);
                        break;

                    case CollisionResolution.Overwrite:
                        var roleGroup = new RoleGroupInfo(local.RoleGroupID, portalId, false)
                        {
                            RoleGroupName = other.RoleGroupName,
                            Description   = other.Description,
                        };
                        RoleController.UpdateRoleGroup(roleGroup, false);
                        changedGroups.Add(new RoleGroupItem(roleGroup.RoleGroupID, createdBy, modifiedBy));
                        DataCache.ClearCache(string.Format(DataCache.RoleGroupsCacheKey, local.RoleGroupID));
                        Result.AddLogEntry("Updated role group", other.RoleGroupName);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(importDto.CollisionResolution.ToString());
                    }
                }
                else
                {
                    var roleGroup = new RoleGroupInfo()
                    {
                        PortalID      = portalId,
                        RoleGroupName = other.RoleGroupName,
                        Description   = other.Description,
                    };
                    other.LocalId = RoleController.AddRoleGroup(roleGroup);
                    changedGroups.Add(new RoleGroupItem(roleGroup.RoleGroupID, createdBy, modifiedBy));
                    Result.AddLogEntry("Added role group", other.RoleGroupName);
                }
            }
            if (changedGroups.Count > 0)
            {
                RefreshRecordsUserIds(changedGroups);
            }
        }
 public ActiveMQMessage() : base()
 {
     Timestamp = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
 }
Example #21
0
        public async Task SwitchMove(Context ctx)
        {
            ctx.CheckSystem();

            var timeToMove = ctx.RemainderOrNull() ?? throw new PKSyntaxError("Must pass a date or time to move the switch to.");
            var tz         = TzdbDateTimeZoneSource.Default.ForId(ctx.System.UiTz ?? "UTC");

            var result = DateUtils.ParseDateTime(timeToMove, true, tz);

            if (result == null)
            {
                throw Errors.InvalidDateTime(timeToMove);
            }

            var time = result.Value;

            if (time.ToInstant() > SystemClock.Instance.GetCurrentInstant())
            {
                throw Errors.SwitchTimeInFuture;
            }

            // Fetch the last two switches for the system to do bounds checking on
            var lastTwoSwitches = await _data.GetSwitches(ctx.System.Id).Take(2).ToListAsync();

            // If we don't have a switch to move, don't bother
            if (lastTwoSwitches.Count == 0)
            {
                throw Errors.NoRegisteredSwitches;
            }

            // If there's a switch *behind* the one we move, we check to make srue we're not moving the time further back than that
            if (lastTwoSwitches.Count == 2)
            {
                if (lastTwoSwitches[1].Timestamp > time.ToInstant())
                {
                    throw Errors.SwitchMoveBeforeSecondLast(lastTwoSwitches[1].Timestamp.InZone(tz));
                }
            }

            // Now we can actually do the move, yay!
            // But, we do a prompt to confirm.
            var lastSwitchMembers   = _data.GetSwitchMembers(lastTwoSwitches[0]);
            var lastSwitchMemberStr = string.Join(", ", await lastSwitchMembers.Select(m => m.NameFor(ctx)).ToListAsync());
            var lastSwitchTimeStr   = lastTwoSwitches[0].Timestamp.FormatZoned(ctx.System);
            var lastSwitchDeltaStr  = (SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[0].Timestamp).FormatDuration();
            var newSwitchTimeStr    = time.FormatZoned();
            var newSwitchDeltaStr   = (SystemClock.Instance.GetCurrentInstant() - time.ToInstant()).FormatDuration();

            // yeet
            var msg = await ctx.Reply($"{Emojis.Warn} This will move the latest switch ({lastSwitchMemberStr}) from {lastSwitchTimeStr} ({lastSwitchDeltaStr} ago) to {newSwitchTimeStr} ({newSwitchDeltaStr} ago). Is this OK?");

            if (!await ctx.PromptYesNo(msg))
            {
                throw Errors.SwitchMoveCancelled;
            }

            // aaaand *now* we do the move
            await _data.MoveSwitch(lastTwoSwitches[0], time.ToInstant());

            await ctx.Reply($"{Emojis.Success} Switch moved.");
        }
Example #22
0
        public static string GetContentByTableStyle(string content, string separator, PublishmentSystemInfo publishmentSystemInfo, ETableStyle tableStyle, TableStyleInfo styleInfo, string formatString, StringDictionary attributes, string innerXml, bool isStlEntity)
        {
            var parsedContent = content;

            var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType);

            if (inputType == EInputType.Date)
            {
                var dateTime = TranslateUtils.ToDateTime(content);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateOnly;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
                else
                {
                    parsedContent = string.Empty;
                }
            }
            else if (inputType == EInputType.DateTime)
            {
                var dateTime = TranslateUtils.ToDateTime(content);
                if (dateTime != DateUtils.SqlMinValue)
                {
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = DateUtils.FormatStringDateTime;
                    }
                    parsedContent = DateUtils.Format(dateTime, formatString);
                }
                else
                {
                    parsedContent = string.Empty;
                }
            }
            else if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne)//选择类型
            {
                var selectedTexts  = new ArrayList();
                var selectedValues = TranslateUtils.StringCollectionToStringList(content);
                var styleItems     = styleInfo.StyleItems ??
                                     BaiRongDataProvider.TableStyleDao.GetStyleItemInfoList(styleInfo.TableStyleId);
                foreach (var itemInfo in styleItems)
                {
                    if (selectedValues.Contains(itemInfo.ItemValue))
                    {
                        selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle);
                    }
                }
                parsedContent = separator == null?TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator);
            }
            //else if (styleInfo.InputType == EInputType.TextArea)
            //{
            //    parsedContent = StringUtils.ReplaceNewlineToBR(parsedContent);
            //}
            else if (inputType == EInputType.TextEditor)
            {
                /****获取编辑器中内容,解析@符号,添加了远程路径处理 20151103****/
                parsedContent = StringUtility.TextEditorContentDecode(parsedContent, publishmentSystemInfo, true);
            }
            else if (inputType == EInputType.Image)
            {
                parsedContent = GetImageOrFlashHtml(publishmentSystemInfo, parsedContent, attributes, isStlEntity);
            }
            else if (inputType == EInputType.Video)
            {
                parsedContent = GetVideoHtml(publishmentSystemInfo, parsedContent, attributes, isStlEntity);
            }
            else if (inputType == EInputType.File)
            {
                parsedContent = GetFileHtmlWithoutCount(publishmentSystemInfo, parsedContent, attributes, innerXml, isStlEntity);
            }

            return(parsedContent);
        }
Example #23
0
        protected override object MakeObjectInstance()
        {
            var logicModel = new ProjectLogicModel(m_userName, m_project);
            var cashflowDt = logicModel.DealSchedule.GetByPaymentDay(m_paymentDay).Dataset.DealModel.CashflowDt;

            var obj = new SpecialPlanTransferInstruction();

            GetMoney(obj, cashflowDt);

            var allBankAccounts = m_dbAdapter.BankAccount.GetAccounts(m_project.ProjectId, true);

            //收款户
            var bankType   = GetBankType();
            var payeeBanks = allBankAccounts.Where(x => x.AccountType == bankType).ToList();

            CommUtils.Assert(payeeBanks.Count < 2, "产品 [" + m_project.Name + "] 的[" + bankType.ToString() + "]不唯一,无法确定收款户。");

            var noPayeeBankMsg = "【缺少" + bankType.ToString() + "信息】";

            if (payeeBanks.Count == 1)
            {
                var payee = payeeBanks[0];
                obj.Payee.Name    = payee.Name;
                obj.Payee.Bank    = payee.IssuerBank;
                obj.Payee.Account = payee.BankAccount;
            }
            else
            {
                obj.Payee.Name    = noPayeeBankMsg;
                obj.Payee.Bank    = noPayeeBankMsg;
                obj.Payee.Account = noPayeeBankMsg;
            }

            //付款户
            var payerBanks = allBankAccounts.Where(x => x.AccountType == EAccountType.专项计划账户).ToList();

            CommUtils.Assert(payerBanks.Count < 2, "产品 [" + m_project.Name + "] 的[专项计划账户]不唯一,无法确定付款户。");

            var noPayerBankMsg = "【缺少" + EAccountType.专项计划账户.ToString() + "信息】";

            if (payerBanks.Count == 1)
            {
                var payer = payerBanks[0];
                obj.Payer.Name    = payer.Name;
                obj.Payer.Bank    = payer.IssuerBank;
                obj.Payer.Account = payer.BankAccount;
            }
            else
            {
                obj.Payer.Name    = noPayerBankMsg;
                obj.Payer.Bank    = noPayerBankMsg;
                obj.Payer.Account = noPayerBankMsg;
            }

            //划付日期 = 当前工作截止日期的下一个工作日
            obj.TransferDate = DateUtils.GetNextTradingDay(m_paymentDay);

            obj.UsesAndComment = m_usesAndComment;

            return(obj);
        }
Example #24
0
        private void Initialize(ProjectLogicModel project)
        {
            var objStr = "产品 [" + project.Instance.Name + "] ";

            var projectId = project.Instance.ProjectId;

            if (project.Instance.Model == null && project.Instance.ModelId > 0)
            {
                project.Instance.Model = m_dbAdapter.Project.GetModel(project.Instance.ModelId);
            }

            var modelFolder = WebConfigUtils.RootFolder + project.Instance.Model.ModelFolder + "\\";

            CommUtils.Assert(Directory.Exists(modelFolder), "找不到模型路径[{0}]", modelFolder);

            DealSchedule dealSchedule = null;

            try
            {
                dealSchedule = NancyUtils.GetDealSchedule(projectId, ignoreException: false);
            }
            catch (Exception e)
            {
                CommUtils.Assert(false, "加载模型失败:[{0}],模型路径:{1}"
                                 + Environment.NewLine + e.Message, modelFolder);
            }
            CommUtils.AssertNotNull(dealSchedule, "加载模型失败:{0}", modelFolder);
            m_instanse = dealSchedule;

            CommUtils.Assert(DateUtils.IsNormalDate(dealSchedule.FirstCollectionPeriodStartDate),
                             "模型中,FirstCollectionPeriodStartDate({0})不是有效的日期", dealSchedule.FirstCollectionPeriodStartDate.ToString());
            CommUtils.Assert(DateUtils.IsNormalDate(dealSchedule.FirstCollectionPeriodEndDate),
                             "模型中,FirstCollectionPeriodEndDate({0})不是有效的日期", dealSchedule.FirstCollectionPeriodEndDate.ToString());

            CommUtils.AssertNotNull(dealSchedule.PaymentDates, objStr + "中没有PaymentDatas数据");
            CommUtils.AssertNotNull(dealSchedule.DeterminationDates, objStr + "中没有DeterminationDates数据");
            CommUtils.AssertEquals(dealSchedule.PaymentDates.Length, dealSchedule.DeterminationDates.Length, objStr + "中DealSchedule数据加载失败");

            _durationPeriods = new List <DatasetScheduleLogicModel>();
            for (int i = 0; i < dealSchedule.PaymentDates.Length; i++)
            {
                var paymentDate    = dealSchedule.PaymentDates[i];
                var durationPeriod = new DatasetScheduleLogicModel(project);
                durationPeriod.Sequence    = m_project.GetAllPaymentDates(dealSchedule.PaymentDates).IndexOf(paymentDate) + 1;
                durationPeriod.PaymentDate = paymentDate;
                if (i == 0)
                {
                    durationPeriod.AsOfDateBegin = dealSchedule.FirstCollectionPeriodStartDate;
                }
                else
                {
                    durationPeriod.AsOfDateBegin = dealSchedule.DeterminationDates[i - 1];
                }

                durationPeriod.AsOfDateEnd = dealSchedule.DeterminationDates[i];

                if (i != 0)
                {
                    durationPeriod.Previous      = _durationPeriods[i - 1];
                    durationPeriod.Previous.Next = durationPeriod;
                }

                _durationPeriods.Add(durationPeriod);
            }

            ClosingDate   = dealSchedule.ClosingDate;
            LegalMaturity = dealSchedule.LegalMaturity;
        }
Example #25
0
        public static void CreateExcelFileForInputContents(string filePath, PublishmentSystemInfo publishmentSystemInfo,
                                                           InputInfo inputInfo)
        {
            DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
            FileUtils.DeleteFileIfExists(filePath);

            var head = new List <string>();
            var rows = new List <List <string> >();

            var relatedidentityes = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent,
                                                                           publishmentSystemInfo.PublishmentSystemId, inputInfo.InputId);
            var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent,
                                                                             DataProvider.InputContentDao.TableName, relatedidentityes);

            if (tableStyleInfoList.Count == 0)
            {
                throw new Exception("表单无字段,无法导出");
            }

            foreach (var tableStyleInfo in tableStyleInfoList)
            {
                head.Add(tableStyleInfo.DisplayName);
            }

            if (inputInfo.IsReply)
            {
                head.Add("回复");
            }
            head.Add("添加时间");

            var contentIdList = DataProvider.InputContentDao.GetContentIdListWithChecked(inputInfo.InputId);

            foreach (var contentId in contentIdList)
            {
                var contentInfo = DataProvider.InputContentDao.GetContentInfo(contentId);
                if (contentInfo != null)
                {
                    var row = new List <string>();

                    foreach (var tableStyleInfo in tableStyleInfoList)
                    {
                        var value = contentInfo.Attributes.Get(tableStyleInfo.AttributeName);

                        if (!string.IsNullOrEmpty(value))
                        {
                            value = InputParserUtility.GetContentByTableStyle(value, publishmentSystemInfo,
                                                                              ETableStyle.InputContent, tableStyleInfo);
                        }

                        row.Add(StringUtils.StripTags(value));
                    }

                    if (inputInfo.IsReply)
                    {
                        row.Add(StringUtils.StripTags(contentInfo.Reply));
                    }
                    row.Add(DateUtils.GetDateAndTimeString(contentInfo.AddDate));

                    rows.Add(row);
                }
            }

            CsvUtils.Export(filePath, head, rows);
        }
Example #26
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets current time in User's timezone
 /// </summary>
 /// <history>
 ///     [aprasad]	07/19/2011	Added
 /// </history>
 /// -----------------------------------------------------------------------------
 public DateTime LocalTime()
 {
     return(LocalTime(DateUtils.GetDatabaseTime()));
 }
Example #27
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string leftText, string rightText, string formatString, string no, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, string isReturnToBrStr, bool isLower, bool isUpper, bool isOriginal, string type, ContentInfo contentInfo, int contentId)
        {
            if (contentInfo == null)
            {
                return(string.Empty);
            }

            var parsedContent = string.Empty;

            if (string.IsNullOrEmpty(type))
            {
                type = ContentAttribute.Title.ToLower();
            }

            var isReturnToBr = false;

            if (string.IsNullOrEmpty(isReturnToBrStr))
            {
                if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    isReturnToBr = true;
                }
            }
            else
            {
                isReturnToBr = TranslateUtils.ToBool(isReturnToBrStr, true);
            }

            if (isOriginal)
            {
                if (contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0 && contentInfo.GetString(ContentAttribute.TranslateContentType) == ETranslateContentType.Reference.ToString())
                {
                    var targetChannelId = contentInfo.SourceId;
                    //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId);
                    var targetSiteId   = StlChannelCache.GetSiteId(targetChannelId);
                    var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
                    var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);

                    //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId);
                    var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contentInfo.ReferenceId);
                    if (targetContentInfo != null && targetContentInfo.ChannelId > 0)
                    {
                        //标题可以使用自己的
                        targetContentInfo.Title = contentInfo.Title;
                        contentInfo             = targetContentInfo;
                    }
                }
            }

            if (!string.IsNullOrEmpty(formatString))
            {
                formatString = formatString.Trim();
                if (!formatString.StartsWith("{0"))
                {
                    formatString = "{0:" + formatString;
                }
                if (!formatString.EndsWith("}"))
                {
                    formatString = formatString + "}";
                }
            }

            if (contentId != 0)
            {
                if (ContentAttribute.Title.ToLower().Equals(type))
                {
                    var nodeInfo          = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId);
                    var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo);
                    var tableName         = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo);

                    var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities);
                    parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo.Title, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false);
                    parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);

                    if (!isClearTags && !string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title))))
                    {
                        parsedContent = ContentUtility.FormatTitle(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)), parsedContent);
                    }

                    if (pageInfo.SiteInfo.Additional.IsContentTitleBreakLine)
                    {
                        parsedContent = parsedContent.Replace("  ", !contextInfo.IsInnerElement ? "<br />" : string.Empty);
                    }
                }
                else if (BackgroundContentAttribute.SubTitle.ToLower().Equals(type))
                {
                    parsedContent = InputTypeUtils.ParseString(InputType.Text, contentInfo.GetString(BackgroundContentAttribute.SubTitle), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                    if (pageInfo.SiteInfo.Additional.IsContentSubTitleBreakLine)
                    {
                        parsedContent = parsedContent.Replace("  ", !contextInfo.IsInnerElement ? "<br />" : string.Empty);
                    }
                }
                else if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    parsedContent = InputTypeUtils.ParseString(InputType.TextArea, contentInfo.GetString(BackgroundContentAttribute.Summary), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                }
                else if (BackgroundContentAttribute.Content.ToLower().Equals(type))
                {
                    parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal);

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }
                }
                else if (ContentAttribute.PageContent.ToLower().Equals(type))
                {
                    //if (contextInfo.IsInnerElement)
                    // {
                    parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal);

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }
                }
                else if (ContentAttribute.AddDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.AddDate, formatString);
                }
                else if (ContentAttribute.LastEditDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.LastEditDate, formatString);
                }
                else if (ContentAttribute.LastHitsDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.LastHitsDate, formatString);
                }
                else if (BackgroundContentAttribute.ImageUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        sbParsedContent.Append(contextInfo.IsStlEntity
                            ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo,
                                                             contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal)
                            : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo,
                                                                     contentInfo.GetString(BackgroundContentAttribute.ImageUrl),
                                                                     contextInfo.Attributes, false));
                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                        var extendValues        = contentInfo.GetString(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                var newExtendValue = extendValue;
                                sbParsedContent.Append(contextInfo.IsStlEntity
                                    ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal)
                                    : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo,
                                                                             newExtendValue, contextInfo.Attributes, false));
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no);
                        if (num <= 1)
                        {
                            parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), contextInfo.Attributes, false);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    var newExtendValue = extendValue;
                                    if (index == num)
                                    {
                                        parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, newExtendValue, contextInfo.Attributes, false);
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.VideoUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity));

                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                        var extendValues        = contentInfo.GetString(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity));
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no);
                        if (num <= 1)
                        {
                            parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    if (index == num)
                                    {
                                        parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity);
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.FileUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        if (contextInfo.IsStlEntity)
                        {
                            //第一条
                            sbParsedContent.Append(contentInfo.GetString(BackgroundContentAttribute.FileUrl));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(extendValue);
                                }
                            }
                        }
                        else
                        {
                            //第一条
                            sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper));
                                }
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no);
                        if (contextInfo.IsStlEntity)
                        {
                            if (num <= 1)
                            {
                                parsedContent = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetString(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = extendValue;
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }

                            if (!string.IsNullOrEmpty(parsedContent))
                            {
                                parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                            }
                        }
                        else
                        {
                            if (num <= 1)
                            {
                                parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetString(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper);
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (ContentAttribute.NavigationUrl.ToLower().Equals(type))
                {
                    parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, pageInfo.IsLocal);
                }
                else if (ContentAttribute.Tags.ToLower().Equals(type))
                {
                    parsedContent = contentInfo.Tags;
                }
                else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null)
                {
                    var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, type, contextInfo);
                    parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString();
                }
                else if (ContentAttribute.AddUserName.ToLower().Equals(type))
                {
                    if (!string.IsNullOrEmpty(contentInfo.AddUserName))
                    {
                        parsedContent = contentInfo.AddUserName;
                    }
                }
                else
                {
                    var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId);

                    if (contentInfo.ContainsKey(type))
                    {
                        if (!StringUtils.ContainsIgnoreCase(ContentAttribute.AllAttributes.Value, type))
                        {
                            var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo);
                            var tableName         = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo);
                            var styleInfo         = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities);

                            //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式
                            var num = TranslateUtils.ToInt(no);
                            parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo, separator, pageInfo.SiteInfo, styleInfo, formatString, num, contextInfo.Attributes, contextInfo.InnerHtml, false);
                            parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                        else
                        {
                            parsedContent = contentInfo.GetString(type);
                            parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(parsedContent))
                {
                    parsedContent = leftText + parsedContent + rightText;
                }
            }

            return(parsedContent);
        }
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == this.applyLightingOverrideEvent)
     {
         this.UnregisterOverrideEvent(this.applyLightingOverrideEvent);
         this.applyLightingOverrideEvent = EventId.Nop;
         this.LoadPlanetLightingData(this.overrideLightingDataAssetName);
         return(EatResponse.NotEaten);
     }
     if (id == this.removeLightingOverrideEvent)
     {
         this.UnregisterOverrideEvent(this.removeLightingOverrideEvent);
         this.removeLightingOverrideEvent = EventId.Nop;
         this.RemoveLightingDataOverride();
         return(EatResponse.NotEaten);
     }
     if (id != EventId.WorldOutTransitionComplete)
     {
         if (id == EventId.GameStateChanged)
         {
             GameStateMachine gameStateMachine = Service.Get <GameStateMachine>();
             IState           currentState     = gameStateMachine.CurrentState;
             uint             timeStamp        = DateUtils.GetNowSeconds();
             if (currentState is BattlePlaybackState)
             {
                 BattleEntry  currentBattleEntry  = Service.Get <BattlePlaybackController>().CurrentBattleEntry;
                 BattleRecord currentBattleRecord = Service.Get <BattlePlaybackController>().CurrentBattleRecord;
                 if (currentBattleEntry != null && currentBattleRecord != null)
                 {
                     uint num = (uint)(currentBattleRecord.BattleLength - currentBattleRecord.BattleAttributes.TimeLeft);
                     timeStamp = currentBattleEntry.EndBattleServerTime - num;
                 }
                 else
                 {
                     timeStamp = (uint)UnityEngine.Random.Range(0, 86400000);
                 }
                 this.CalculateInitialPlanetLightingData(timeStamp);
             }
             else if (currentState is HomeState)
             {
                 this.UnlockAndRestoreTimeOfDay();
             }
             else if (this.IsTimePausedInDayPhase())
             {
                 this.SetTimeOfDayColorToTheDayPhase();
             }
             this.RefreshPlanetData(timeStamp);
         }
     }
     else
     {
         this.ClearLightingDataOverride();
         CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle();
         if (currentBattle != null && !currentBattle.IsPvP() && !currentBattle.IsDefense())
         {
             this.pauseTimeOfDayUpdate = true;
             this.SetTimeOfDayColorToTheDayPhase();
         }
     }
     return(EatResponse.NotEaten);
 }
Example #29
0
 public Attack(User user, DetectionPoint detectionPoint, string detectionSystemId)
 {
     InitClass(user, detectionPoint, DateUtils.getCurrentTimestampAsString(), detectionSystemId);
 }
Example #30
0
        static void Main(string[] args)
        {
            // select you endpoint https://help.aliyun.com/document_detail/29008.html
            String endpoint    = "your project region endpoint",
                   accesskeyId = "your accesskey id",
                   accessKey   = "your access key",
                   project     = "",
                   logstore    = "";
            LogClient client   = new LogClient(endpoint, accesskeyId, accessKey);

            //init http connection timeout
            client.ConnectionTimeout = client.ReadWriteTimeout = 10000;
            //list logstores
            foreach (String l in client.ListLogstores(new ListLogstoresRequest(project)).Logstores)
            {
                Console.WriteLine(l);
            }
            //put logs
            PutLogsRequest putLogsReqError = new PutLogsRequest();

            putLogsReqError.Project  = project;
            putLogsReqError.Topic    = "dotnet_topic";
            putLogsReqError.Logstore = logstore;
            putLogsReqError.LogItems = new List <LogItem>();
            for (int i = 1; i <= 10; ++i)
            {
                LogItem logItem = new LogItem();
                logItem.Time = DateUtils.TimeSpan();
                for (int k = 0; k < 10; ++k)
                {
                    logItem.PushBack("error_" + i.ToString(), "invalid operation");
                }
                putLogsReqError.LogItems.Add(logItem);
            }
            PutLogsResponse putLogRespError = client.PutLogs(putLogsReqError);

            Thread.Sleep(5000);

            //query logs, if query string is "", it means query all data
            GetLogsRequest getLogReq = new GetLogsRequest(project,
                                                          logstore,
                                                          DateUtils.TimeSpan() - 100,
                                                          DateUtils.TimeSpan(),
                                                          "dotnet_topic",
                                                          "",
                                                          100,
                                                          0,
                                                          false);
            GetLogsResponse getLogResp = client.GetLogs(getLogReq);

            Console.WriteLine("Log count : " + getLogResp.Logs.Count.ToString());
            for (int i = 0; i < getLogResp.Logs.Count; ++i)
            {
                var log = getLogResp.Logs[i];
                Console.WriteLine("Log time : " + DateUtils.GetDateTime(log.Time));
                for (int j = 0; j < log.Contents.Count; ++j)
                {
                    Console.WriteLine("\t" + log.Contents[j].Key + " : " + log.Contents[j].Value);
                }
                Console.WriteLine("");
            }

            //query histogram
            GetHistogramsResponse getHisResp = client.GetHistograms(new GetHistogramsRequest(project,
                                                                                             logstore,
                                                                                             DateUtils.TimeSpan() - 100,
                                                                                             DateUtils.TimeSpan(),
                                                                                             "dotnet_topic",
                                                                                             ""));

            Console.WriteLine("Histograms total count : " + getHisResp.TotalCount.ToString());

            //list shards
            ListShardsResponse listResp = client.ListShards(new ListShardsRequest(project, logstore));

            Console.WriteLine("Shards count : " + listResp.Shards.Count.ToString());

            //batch get logs
            for (int i = 0; i < listResp.Shards.Count; ++i)
            {
                //get cursor
                String cursor = client.GetCursor(new GetCursorRequest(project, logstore, listResp.Shards[i], ShardCursorMode.BEGIN)).Cursor;
                Console.WriteLine("Cursor : " + cursor);
                BatchGetLogsResponse batchGetResp = client.BatchGetLogs(new BatchGetLogsRequest(project, logstore, listResp.Shards[i], cursor, 10));
                Console.WriteLine("Batch get log, shard id : " + listResp.Shards[i].ToString() + ", log count : " + batchGetResp.LogGroupList.LogGroupList_Count.ToString());
            }
        }