예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PageSize >= 0)
        {
            gridElem.Pager.DefaultPageSize = PageSize;
        }
        gridElem.OrderBy        = OrderBy;
        gridElem.WhereCondition = WhereCondition;
        if (SiteID > 0)
        {
            gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "ActivitySiteID = " + SiteID);
        }
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        // Set gridelement empty list info text either to set property or default value
        gridElem.ZeroRowsText = ((ZeroRowsText == null) ? GetString("om.activities.noactivities") : GetString(ZeroRowsText));

        if (ContactID > 0)
        {
            gridElem.ObjectType = "om.activitycontactlist";
            if (IsMergedContact)
            {
                gridElem.ObjectType = "om.activitycontactmergedlist";
            }
            if (IsGlobalContact)
            {
                gridElem.ObjectType = "om.activitycontactgloballist";
            }

            QueryDataParameters parameters = new QueryDataParameters();
            parameters.AddId("@ContactID", ContactID);

            gridElem.QueryParameters = parameters;
        }

        // Check permission modify for current site only. To be able to display other sites user must be global admin = no need to check permission.
        modifyPermission = ActivityHelper.AuthorizedManageActivity(CMSContext.CurrentSiteID, false);

        ScriptHelper.RegisterDialogScript(Page);

        string scriptBlock = string.Format(@"
            function ViewDetails(id) {{ modalDialog('{0}' + id, 'ActivityDetails', '900', '700'); return false; }}",
                                           ResolveUrl(@"~/CMSModules/ContactManagement/Pages/Tools/Activities/Activity/Activity_Details.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);
    }
예제 #2
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[] {
         new StateVariable
         {
             Name = "SourceString",
             Value = SourceString,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = "ResultsCollection",
             Value = ActivityHelper.GetSerializedStateValueFromCollection(ResultsCollection),
             Type = StateVariable.StateType.Output
         }
     });
 }
예제 #3
0
        public void Can_Stop_Activity_With_AspNetListener_Enabled()
        {
            var context      = HttpContextHelper.GetFakeHttpContext();
            var rootActivity = new Activity(TestActivityName);

            rootActivity.Start();
            context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder {
                Activity = rootActivity
            };
            Thread.Sleep(100);
            this.EnableListener();
            ActivityHelper.StopAspNetActivity(this.noopTextMapPropagator, rootActivity, context, null);

            Assert.True(rootActivity.Duration != TimeSpan.Zero);
            Assert.Null(rootActivity.Parent);
            Assert.Null(context.Items[ActivityHelper.ContextKey]);
        }
예제 #4
0
파일: UserService.cs 프로젝트: Lanc3000/CRM
        public List <ObjRole> GetRoles()
        {
            var roles      = _roleRepository.GetRoles();
            var activities = ActivityHelper.GetActivities();

            return(roles.Select(x => new ObjRole()
            {
                Id = x.Id,
                Title = x.Title,
                Name = x.Name,
                RoleActivitys = activities
                                .Where(a => a.Permisioins.Any(p => x.RoleActivitys.Any(ac => ac.Activity == p.Key)))
                                .Select(a => $"{a.Title} ({string.Join(", ", a.Permisioins.Where(p => x.RoleActivitys.Any(ac => ac.Activity == p.Key)).Select(p => p.Title.ToLower()))})")
                                .ToList()
            })
                   .ToList());
        }
예제 #5
0
        public void Can_Create_RootActivity_And_Ignore_Info_From_Request_Header_If_ParseHeaders_Is_False()
        {
            var requestHeaders = new Dictionary <string, string>
            {
                { ActivityExtensions.RequestIDHeaderName, "|aba2f1e978b2cab6.1." },
                { ActivityExtensions.CorrelationContextHeaderName, this.baggageInHeader }
            };

            var context = HttpContextHelper.GetFakeHttpContext(headers: requestHeaders);

            this.EnableAspNetListenerAndActivity();
            var rootActivity = ActivityHelper.CreateRootActivity(context, parseHeaders: false);

            Assert.NotNull(rootActivity);
            Assert.Null(rootActivity.ParentId);
            Assert.Empty(rootActivity.Baggage);
        }
        public void DsfDataMergeActivity_GetState_Returns_Inputs_And_Outputs()
        {
            //------------Setup for test--------------------------
            _mergeCollection.Clear();
            _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left"));
            var act = new DsfDataMergeActivity {
                Result = "[[res]]", MergeCollection = _mergeCollection
            };

            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            //------------Assert Results-------------------------
            Assert.AreEqual(2, stateItems.Count());
            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Merge Collection",
                    Type  = StateVariable.StateType.Input,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(_mergeCollection)
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = act.Result
                }
            };

            var iter = act.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
예제 #7
0
        public void DsfXPathActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1));
            //------------Setup for test--------------------------
            var act = new DsfXPathActivity {
                SourceString = "xml", ResultsCollection = _resultsCollection
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            Assert.AreEqual(2, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "SourceString",
                    Type  = StateVariable.StateType.Input,
                    Value = "xml"
                },
                new StateVariable
                {
                    Name  = "ResultsCollection",
                    Type  = StateVariable.StateType.Output,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(_resultsCollection)
                }
            };

            var iter = act.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
예제 #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                SubCategories _category1 = new SubCategories();
                int           catId      = Convert.ToInt32(ddlCategory.SelectedValue);
                _category1 = bSubCategory.List().Where(m => m.Category_Id == catId && m.SubCategory_Title == txtCategory.Text).FirstOrDefault();
                int adminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
                if (_category1 == null)
                {
                    SubCategories SubCategories = new SubCategories()
                    {
                        SubCategory_Title       = txtCategory.Text,
                        Administrators_Id       = adminId,
                        Category_Id             = Convert.ToInt32(ddlCategory.SelectedValue),
                        SubCategory_CreatedDate = DateTime.Now,
                        SubCategory_UpdatedDate = DateTime.Now,
                        SubCategory_Status      = eStatus.Active.ToString()
                    };

                    bSubCategory.Create(SubCategories);
                    ActivityHelper.Create("New Sub Category", "New Sub Category Created On " + DateTime.Now.ToString("D") + " Successfully and Title is " + SubCategories.SubCategory_Title + ".", adminId);

                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "New Sub Category Created Successfully..";
                    ClearFields();
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Sub Category cannot be created. Entered Sub Category Name already exists in the database.";
                }
            }
            catch (Exception ex)
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = ex.Message;
            }
        }
예제 #9
0
        void Initialize(string display)
        {
            var           expressionText  = ModelItem.Properties[GlobalConstants.SwitchExpressionTextPropertyText];
            ModelProperty switchCaseValue = ModelItem.Properties["Case"];
            Dev2Switch    ds;

            if (expressionText?.Value != null)
            {
                ds = new Dev2Switch();
                var val = ActivityHelper.ExtractData(expressionText.Value.ToString());
                if (!string.IsNullOrEmpty(val))
                {
                    ds.SwitchVariable = val;
                }
            }
            else
            {
                ds = DataListConstants.DefaultSwitch;
            }
            if (string.IsNullOrEmpty(display))
            {
                var displayName = ModelItem.Properties[GlobalConstants.DisplayNamePropertyText];
                if (displayName?.Value != null)
                {
                    ds.DisplayText = displayName.Value.ToString();
                }
            }
            else
            {
                ds.DisplayText = display;
            }
            if (switchCaseValue != null)
            {
                string val = switchCaseValue.ComputedValue.ToString();
                ds.SwitchExpression = val;
            }

            SwitchVariable   = ds.SwitchVariable;
            SwitchExpression = ds.SwitchExpression;
            DisplayText      = ds.DisplayText;
            if (DisplayText != SwitchVariable && DisplayText != "Switch")
            {
                _hascustomeDisplayText = true;
            }
        }
예제 #10
0
        public SuccessfulMessageResponse DeletBoard([FromBody] BoardsRemovedModel model, string token)
        {
            var session       = IsTokenExpired(token);
            var account       = _readOnlyRepository.GetById <Account>(session.User.Id);
            var boardToRemove = _readOnlyRepository.GetById <Board>(model.Id);

            if (boardToRemove != null && boardToRemove.Administrador == account)
            {
                Board boardDeleted = _writeOnlyRepository.Archive(boardToRemove);
                if (boardDeleted != null)
                {
                    string activityDone = "Deleted " + boardToRemove.Title;
                    boardToRemove.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                    return(new SuccessfulMessageResponse("The board has been deleted"));
                }
            }
            throw new BadRequestException("You aren't the administrator of the Board");
        }
예제 #11
0
        public BoardModel AddMemberToBoard([FromBody] AddMemberBoardModel model, string token)
        {
            var session     = IsTokenExpired(token);
            var memberToAdd = _readOnlyRepository.GetById <Account>(model.MemberId);
            var board       = _readOnlyRepository.GetById <Board>(model.BoardId);

            if (board != null && memberToAdd != null)
            {
                board.AddMember(memberToAdd);
                memberToAdd.AddBoard(board);
                var    updateBoard  = _writeOnlyRepository.Update(board);
                var    boardModel   = _mappingEngine.Map <Board, BoardModel>(updateBoard);
                string activityDone = "Add " + memberToAdd.FirstName + " " + memberToAdd.LastName;
                board.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                return(boardModel);
            }
            throw  new BadRequestException("Member or Board does not exist");
        }
예제 #12
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[]
     {
         new StateVariable
         {
             Name = "JsonMappings",
             Type = StateVariable.StateType.Input,
             Value = ActivityHelper.GetSerializedStateValueFromCollection(JsonMappings)
         },
         new StateVariable
         {
             Name = "JsonString",
             Type = StateVariable.StateType.Output,
             Value = JsonString
         }
     });
 }
예제 #13
0
 void gridElem_OnAction(string actionName, object actionArgument)
 {
     switch (actionName)
     {
     case "delete":
         int activityTypeID = ValidationHelper.GetInteger(actionArgument, 0);
         var activityType   = ActivityTypeInfoProvider.GetActivityTypeInfo(activityTypeID);
         if ((activityType == null) || !activityType.ActivityTypeIsCustom)
         {
             RedirectToInformation("general.modifynotallowed");
         }
         if (ActivityHelper.AuthorizedManageActivity(SiteContext.CurrentSiteID, false))
         {
             ActivityTypeInfoProvider.DeleteActivityTypeInfo(activityType);
         }
         break;
     }
 }
예제 #14
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[]
     {
         new StateVariable
         {
             Name = "Merge Collection",
             Type = StateVariable.StateType.Input,
             Value = ActivityHelper.GetSerializedStateValueFromCollection(MergeCollection)
         },
         new StateVariable
         {
             Name = "Result",
             Type = StateVariable.StateType.Output,
             Value = Result
         }
     });
 }
        /**
         * Handle {@link TracksQuery} {@link Cursor}.
         */
        private void OnTrackQueryComplete(ICursor cursor)
        {
            try {
                if (!cursor.MoveToFirst())
                {
                    return;
                }

                // Use found track to build title-bar
                ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
                String         trackName      = cursor.GetString(TracksQuery.TRACK_NAME);
                activityHelper.SetActionBarTitle(new Java.Lang.String(trackName));
                activityHelper.SetActionBarColor(new Color(cursor.GetInt(TracksQuery.TRACK_COLOR)));
                //AnalyticsUtils.getInstance(getActivity()).trackPageView("/Tracks/" + trackName);
            } finally {
                cursor.Close();
            }
        }
예제 #16
0
        public void Can_Stop_Root_Activity_With_All_Children()
        {
            this.EnableListener();
            var context = HttpContextHelper.GetFakeHttpContext();

            using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null);

            var child = new Activity("child").Start();

            new Activity("grandchild").Start();

            ActivityHelper.StopAspNetActivity(this.noopTextMapPropagator, rootActivity, context, null);

            Assert.True(rootActivity.Duration != TimeSpan.Zero);
            Assert.True(child.Duration == TimeSpan.Zero);
            Assert.Null(rootActivity.Parent);
            Assert.Null(context.Items[ActivityHelper.ContextKey]);
        }
        public void Stop_Root_Activity_With_129_Nesting_Depth()
        {
            this.EnableAll();
            var context = HttpContextHelper.GetFakeHttpContext();
            var root    = ActivityHelper.CreateRootActivity(context, false);

            for (int i = 0; i < 129; i++)
            {
                new Activity("child" + i).Start();
            }

            // can stop any activity regardless of the stack depth
            ActivityHelper.StopAspNetActivity(context.Items);

            Assert.True(root.Duration != TimeSpan.Zero);
            Assert.Null(context.Items[ActivityHelper.ActivityKey]);
            Assert.Null(Activity.Current);
        }
        public void Stop_Root_Activity_With_129_Nesting_Depth()
        {
            this.EnableListener();
            var context = HttpContextHelper.GetFakeHttpContext();
            var root    = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null);

            for (int i = 0; i < 129; i++)
            {
                new Activity("child" + i).Start();
            }

            // can stop any activity regardless of the stack depth
            ActivityHelper.StopAspNetActivity(this.noopTextMapPropagator, root, context, null);

            Assert.True(root.Duration != TimeSpan.Zero);
            Assert.Null(context.Items[ActivityHelper.ActivityKey]);
            Assert.NotNull(Activity.Current);
        }
예제 #19
0
        public async Task Can_Restore_Activity()
        {
            var rootActivity = this.CreateActivity();

            rootActivity.AddTag("k1", "v1");
            rootActivity.AddTag("k2", "v2");
            var context = HttpContextHelper.GetFakeHttpContext();
            await Task.Run(() =>
            {
                rootActivity.Start();
                context.Items[ActivityHelper.ActivityKey] = rootActivity;
            });

            Assert.Null(Activity.Current);

            ActivityHelper.RestoreActivityIfNeeded(context.Items);

            this.AssertIsRestoredActivity(rootActivity, Activity.Current);
        }
예제 #20
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            sda = new SqlDataAccess();
            sda.openConnection(Globals.ConnectionString);

            try
            {
                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region | ADD PHONE NUMBER |
                ActivityHelper.AddPhoneNumber(entity, service);
                #endregion | ADD PHONE NUMBER |
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }
예제 #21
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(PrizeQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                PageModel <ViewUserAwardRecordsInfo> allAwardRecordsByActityId = ActivityHelper.GetAllAwardRecordsByActityId(query);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = allAwardRecordsByActityId.Total;
                foreach (ViewUserAwardRecordsInfo model in allAwardRecordsByActityId.Models)
                {
                    Dictionary <string, object> dictionary = model.ToDictionary();
                    dictionary.Add("AwardGradeText", this.GetWeekCN(model.AwardGrade));
                    dictionary.Add("StatusText", (model.Status == 2) ? "已领奖" : "未领奖");
                    dataGridViewModel.rows.Add(dictionary);
                }
            }
            return(dataGridViewModel);
        }
예제 #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         for (int i = 1; i <= 10; i++)
         {
             string text = "每人参与" + i.ToString() + "次";
             this.ddl_maxNum.Items.Add(new ListItem(text, i.ToString()));
         }
         this.ddl_maxNum.Items.Add(new ListItem("不限", "0"));
         this.hasPartProductAct = ActivityHelper.HasPartProductAct();
     }
     this.IsView = Globals.RequestQueryNum("View");
     if (base.Request.Params.AllKeys.Contains <string>("id") && base.Request["id"].ToString().bInt(ref this._id))
     {
         this._act = ActivityHelper.GetAct(this._id);
         if (this._act == null)
         {
             this.ShowMsg("没有这个满减活动~", false);
         }
         if (this._act.StartTime < DateTime.Now)
         {
             this.IsView = 1;
         }
         this.txt_name.Text = this._act.ActivitiesName;
         this.calendarStartDate.SelectedDate = new DateTime?(this._act.StartTime);
         this.calendarEndDate.SelectedDate   = new DateTime?(this._act.EndTime);
         this.ddl_maxNum.SelectedValue       = this._act.attendTime.ToString();
         this._json        = JsonConvert.SerializeObject(this._act.Details);
         this.isAllProduct = this._act.isAllProduct;
         HiddenField field  = this.SetMemberRange.FindControl("txt_Grades") as HiddenField;
         HiddenField field2 = this.SetMemberRange.FindControl("txt_DefualtGroup") as HiddenField;
         HiddenField field3 = this.SetMemberRange.FindControl("txt_CustomGroup") as HiddenField;
         this.SetMemberRange.Grade        = this._act.MemberGrades;
         this.SetMemberRange.DefualtGroup = this._act.DefualtGroup;
         this.SetMemberRange.CustomGroup  = this._act.CustomGroup;
         field.Value  = this._act.MemberGrades;
         field2.Value = this._act.DefualtGroup;
         field3.Value = this._act.CustomGroup;
         DataTable table = ActivityHelper.QueryProducts(this._id);
         this.productCount.InnerText = (table != null) ? table.Rows.Count.ToString() : "0";
     }
 }
예제 #23
0
        public async Task Stop_Restored_Activity_Deletes_It_From_Items()
        {
            var context = HttpContextHelper.GetFakeHttpContext();
            var root    = new Activity("root");

            await Task.Run(() =>
            {
                root.Start();
                context.Items[ActivityHelper.ActivityKey] = root;
            });

            ActivityHelper.RestoreActivityIfNeeded(context.Items);

            var child = Activity.Current;

            ActivityHelper.StopRestoredActivity(child, context);
            Assert.NotNull(context.Items[ActivityHelper.ActivityKey]);
            Assert.Null(context.Items[ActivityHelper.RestoredActivityKey]);
        }
예제 #24
0
        public void Stop_Root_Activity_With_129_Nesting_Depth()
        {
            var context = HttpContextHelper.GetFakeHttpContext();
            var root    = new Activity("root").Start();

            context.Items[ActivityHelper.ActivityKey] = root;

            for (int i = 0; i < 129; i++)
            {
                new Activity("child" + i).Start();
            }

            // we do not allow more than 128 nested activities here
            // only to protect from hypothetical cycles in Activity stack
            Assert.False(ActivityHelper.StopAspNetActivity(root, context.Items));

            Assert.NotNull(context.Items[ActivityHelper.ActivityKey]);
            Assert.Null(Activity.Current);
        }
예제 #25
0
        public SuccessfulMessageResponse DeletCard([FromBody] CardRemoveModel model, string token)
        {
            var session      = IsTokenExpired(token);
            var cardToRemove = _readOnlyRepository.GetById <Card>(model.Card_id);
            var lane         = _readOnlyRepository.First <Lane>(lane1 => lane1.Cards.Contains(cardToRemove));
            var board        = _readOnlyRepository.First <Board>(board1 => board1.Lanes.Contains(lane));

            if (cardToRemove != null)
            {
                Card cardDeleted = _writeOnlyRepository.Archive(cardToRemove);
                if (cardDeleted != null)
                {
                    string activityDone = "Deleted " + cardDeleted.Text + " from " + lane.Title;
                    board.AddActivity(ActivityHelper.CreateActivity(session.User, activityDone));
                    return(new SuccessfulMessageResponse("Card was successfully removed"));
                }
            }
            throw new BadRequestException("Card could not be removed");
        }
예제 #26
0
        // GET Activity/Home/
        public ActionResult ActivityIndex()
        {
            //var dbContext = ContextFactory.GetCurrentContext();
            var sessionKey = Session["firstTime"];

            if (sessionKey == null)
            {
                var baseNumber     = 1000;
                var textPath       = Server.MapPath("~") + "Areas\\Activity\\ActivityConfiguration.txt";
                var configContent  = TextProcessHelper.GetTextLines(textPath);
                var awardModelList = new List <AwardModel>();
                var awardStrList   = new List <string[]>();
                //configContent.RemoveAt(0);
                foreach (var content in configContent)
                {
                    var award = new AwardModel();
                    if (!content.StartsWith("id"))
                    {
                        var line = content.Split(',');
                        award.AwardId      = line[0];
                        award.RatioBegain  = line[1];
                        award.RatioEnd     = line[2];
                        award.AwardMessage = line[3];
                        award.IsAward      = bool.Parse(line[4]);
                        awardModelList.Add(award);
                        var strLine = new string[] { award.RatioBegain, award.RatioEnd, award.AwardId };
                        awardStrList.Add(strLine);
                    }
                }
                var awardId    = ActivityHelper.GetAwardId(baseNumber, awardStrList);
                var awardModel = awardModelList.Where(o => o.AwardId == awardId).FirstOrDefault();
                Session["firstTime"] = true;
                return(View("Index", awardModel));
            }
            else
            {
                var awardModel = new AwardModel()
                {
                    AwardMessage = "您已参过抽奖啦!", IsAward = false
                };
                return(View("Index", awardModel));
            }
        }
예제 #27
0
        protected override void AttachChildControls()
        {
            int num = this.Page.Request["ActivityId"].ToInt(0);

            if (num <= 0)
            {
                base.GotoResourceNotFound("活动不存在");
            }
            else
            {
                this.hdTitle           = (HtmlInputHidden)this.FindControl("hdTitle");
                this.hdAppId           = (HtmlInputHidden)this.FindControl("hdAppId");
                this.hdDesc            = (HtmlInputHidden)this.FindControl("hdDesc");
                this.hdImgUrl          = (HtmlInputHidden)this.FindControl("hdImgUrl");
                this.hdLink            = (HtmlInputHidden)this.FindControl("hdLink");
                this.hdIsLogined       = (HtmlInputHidden)this.FindControl("hdIsLogined");
                this.hdIsLogined.Value = ((HiContext.Current.UserId == 0) ? "0" : "1");
                this.hidPoint          = (HtmlInputHidden)this.FindControl("hidPoint");
                ActivityInfo activityInfo = ActivityHelper.GetActivityInfo(num);
                if (activityInfo == null || activityInfo.ActivityType != 1)
                {
                    base.GotoResourceNotFound("活动不存在");
                }
                else
                {
                    if (HiContext.Current.User != null)
                    {
                        this.hidPoint.Value = HiContext.Current.User.Points.ToString();
                    }
                    if (base.ClientType == ClientType.VShop)
                    {
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                        string       local          = (!string.IsNullOrWhiteSpace(activityInfo.SharePic)) ? activityInfo.SharePic : string.Format("http://{0}/{1}", masterSettings.SiteUrl, "Templates/common/images/bigwheelShare.jpg");
                        this.hdImgUrl.Value = Globals.FullPath(local);
                        this.hdTitle.Value  = activityInfo.ActivityName;
                        this.hdDesc.Value   = activityInfo.ShareDetail;
                        this.hdLink.Value   = Globals.FullPath($"/vshop/BigWheel.aspx?ActivityId={num}");
                        this.hdAppId.Value  = masterSettings.WeixinAppId;
                    }
                    PageTitle.AddSiteNameTitle(activityInfo.ActivityName);
                }
            }
        }
예제 #28
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         int    couponId = int.Parse(context.Request["id"].ToString());
         string s        = context.Request["products"].ToString();
         bool   flag     = bool.Parse(context.Request["bsingle"].ToString());
         bool   flag2    = bool.Parse(context.Request["setSale"].ToString());
         bool   flag3    = false;
         if (!flag)
         {
             bool           isAllProduct = bool.Parse(context.Request["all"].ToString());
             IList <string> productIDs   = s.Split(new char[] { '|' });
             flag3 = ActivityHelper.AddProducts(couponId, isAllProduct, productIDs);
             if (flag2)
             {
                 ProductHelper.UpShelf(s.Replace('|', ','));
             }
         }
         else
         {
             int productID = int.Parse(s);
             flag3 = ActivityHelper.AddProducts(couponId, productID);
             if (flag2)
             {
                 ProductHelper.UpShelf(productID.ToString());
             }
         }
         if (flag3)
         {
             context.Response.Write("{\"type\":\"success\",\"data\":\"添加商品成功\"}");
         }
         else
         {
             context.Response.Write("{\"type\":\"success\",\"data\":\"写数据库失败\"}");
         }
     }
     catch (Exception exception)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + exception.Message + "\"}");
     }
 }
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[]
     {
         new StateVariable
         {
             Name = "SharepointServerResourceId",
             Type = StateVariable.StateType.Input,
             Value = SharepointServerResourceId.ToString()
         },
         new StateVariable
         {
             Name = "FilterCriteria",
             Type = StateVariable.StateType.Input,
             Value = ActivityHelper.GetSerializedStateValueFromCollection(FilterCriteria)
         },
         new StateVariable
         {
             Name = "ReadListItems",
             Type = StateVariable.StateType.Input,
             Value = ActivityHelper.GetSerializedStateValueFromCollection(ReadListItems)
         },
         new StateVariable
         {
             Name = "SharepointList",
             Type = StateVariable.StateType.Input,
             Value = SharepointList
         },
         new StateVariable
         {
             Name = "RequireAllCriteriaToMatch",
             Type = StateVariable.StateType.Input,
             Value = RequireAllCriteriaToMatch.ToString()
         }
         , new StateVariable
         {
             Name = "DeleteCount",
             Type = StateVariable.StateType.Output,
             Value = DeleteCount
         }
     });
 }
        public void Can_Stop_Lost_Activity()
        {
            this.EnableAll(pair =>
            {
                Assert.NotNull(Activity.Current);
                Assert.Equal(ActivityHelper.AspNetActivityName, Activity.Current.OperationName);
            });
            var context      = HttpContextHelper.GetFakeHttpContext();
            var rootActivity = ActivityHelper.CreateRootActivity(context, false);

            rootActivity.AddTag("k1", "v1");
            rootActivity.AddTag("k2", "v2");

            Activity.Current = null;

            ActivityHelper.StopAspNetActivity(context.Items);
            Assert.True(rootActivity.Duration != TimeSpan.Zero);
            Assert.Null(Activity.Current);
            Assert.Null(context.Items[ActivityHelper.ActivityKey]);
        }