当前位置: 首页>>代码示例>>C#>>正文


C# Activity.Save方法代码示例

本文整理汇总了C#中Activity.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.Save方法的具体用法?C# Activity.Save怎么用?C# Activity.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Activity的用法示例。


在下文中一共展示了Activity.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserRequestsToCreateActivity

 protected void UserRequestsToCreateActivity(object sender, ActiveEventArgs e)
 {
     DateTime dt = e.Params["Date"].Get<DateTime>();
     Activity a = new Activity();
     a.Start = dt;
     a.End = dt.AddHours(1);
     a.Creator = ActiveType<User>.SelectFirst(Criteria.Eq("Username", Users.LoggedInUserName));
     a.Header = "Name of activity";
     a.Body = "Body of activity";
     a.Save();
     e.Params["IDOfSaved"].Value = a.ID;
 }
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:12,代码来源:CalendarController.cs

示例2: submit

    protected void submit(object sender, EventArgs e)
    {
        //PopFormValues(); // in case sendby isn't populated
        if (SendBy.DateTimeValue < DateTime.Now.AddDays(-1))
            return;
        if (RequestedFor.LookupResultValue != null)
        {
            Sage.Platform.Application.IContextService conserv = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Application.IContextService>(true);
            Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)conserv.GetContext("TimeZone");

            ILitRequest lr = EntityFactory.Create<ILitRequest>();
            SLXUserService slxUserService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>() as SLXUserService;
            if (slxUserService != null)
            {
                lr.RequestUser = slxUserService.GetUser();
            }
            String[] arClientData = clientdata.Value.ToString().Split('|');
            lr.RequestDate = DateTime.Now.AddMinutes(tz.BiasForGivenDate(DateTime.Now));
            lr.CoverId = arClientData[0];
            lr.Contact = (IContact)RequestedFor.LookupResultValue;
            lr.ContactName = lr.Contact.LastName + ", " + lr.Contact.FirstName;
            lr.Description = Description.Text;
            lr.SendDate = SendBy.DateTimeValue;
            lr.SendVia = SendVia.PickListValue;
            lr.Priority = Priority.PickListValue;
            lr.Options = PrintLiteratureList.SelectedIndex;
            lr.Save();

            Activity act = new Activity();
            act.Type = ActivityType.atLiterature;
            act.AccountId = lr.Contact.Account.Id.ToString();
            act.AccountName = lr.Contact.Account.AccountName;
            act.ContactId = lr.Contact.Id.ToString();
            act.ContactName = lr.ContactName;
            act.PhoneNumber = lr.Contact.WorkPhone;
            act.StartDate = (DateTime)lr.RequestDate;
            act.Duration = 0;
            act.Description = lr.Description;
            act.Alarm = false;
            act.Timeless = true;
            act.Rollover = false;
            act.UserId = lr.RequestUser.Id.ToString();
            act.OriginalDate = (DateTime)lr.RequestDate;
            act.Save();

            //no lit items entitiy, so....
            double totalCost = 0.0;
            string SQL = "INSERT INTO LITREQUESTITEM (LITREQID, LITERATUREID, QTY) VALUES (?,?,?)"; //@Litreqid, @Literatureid, @Qty)";
            IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get<IDataService>();
            var conn = service.GetOpenConnection();
            try
            {
                var cmd = conn.CreateCommand();
                var factory = service.GetDbProviderFactory();
                for (int i = 1; i < arClientData.Length; i++)
                {
                    cmd.CommandText = SQL;
                    int qty = Int32.Parse(arClientData[i].ToString().Split('=')[1]);
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(factory.CreateParameter("@Litreqid", act.Id));
                    cmd.Parameters.Add(factory.CreateParameter("@Literatureid", arClientData[i].ToString().Split('=')[0]));
                    cmd.Parameters.Add(factory.CreateParameter("@Qty", qty));
                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();
                    cmd.CommandText = "SELECT COST FROM LITERATURE WHERE LITERATUREID = ?";
                    cmd.Parameters.Add(factory.CreateParameter("@Litid", arClientData[i].ToString().Split('=')[0]));
                    string costText = cmd.ExecuteScalar().ToString();
                    if (string.IsNullOrEmpty(costText))
                        costText = "0.00";
                    totalCost += qty * Double.Parse(costText);
                }
                cmd.CommandText = "SELECT NAME FROM PLUGIN WHERE PLUGINID = ?";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(factory.CreateParameter("@Litid", lr.CoverId));
                object coverName = cmd.ExecuteScalar();
                if (coverName == null)
                {
                    lr.CoverName = "";
                }
                else
                {
                    lr.CoverName = coverName.ToString();
                }
                lr.TotalCost = totalCost;
                lr.Save();  //must make ids match, and id prop is read only, so....
                cmd.CommandText = String.Format("UPDATE LITREQUEST SET LITREQID = '{0}' WHERE LITREQID = '{1}'", act.Id.ToString(), lr.Id.ToString());
                cmd.Parameters.Clear();
                cmd.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
            Response.Redirect("Contact.aspx?entityId=" + lr.Contact.Id.ToString());
        }
    }
开发者ID:RyanTest,项目名称:SalesLogix_Eval,代码行数:96,代码来源:LiteratureRequest.ascx.cs

示例3: Save

    protected void Save(object sender, EventArgs e)
    {
        if (SendBy.DateTimeValue < DateTime.Now.AddDays(-1))
            return;
        if (RequestedFor.LookupResultValue != null)
        {
            IContextService conserv = ApplicationContext.Current.Services.Get<IContextService>(true);
            Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)conserv.GetContext("TimeZone");

            ILitRequest lr = EntityFactory.Create<ILitRequest>();
            SLXUserService slxUserService = ApplicationContext.Current.Services.Get<IUserService>() as SLXUserService;
            if (slxUserService != null)
            {
                lr.RequestUser = slxUserService.GetUser();
            }
            String[] arClientData = clientdata.Value.ToString().Split('|');
            lr.RequestDate = DateTime.Now.AddMinutes(tz.BiasForGivenDate(DateTime.Now));
            lr.CoverId = arClientData[0];
            lr.Contact = (IContact)RequestedFor.LookupResultValue;
            lr.ContactName = lr.Contact.LastName + ", " + lr.Contact.FirstName;
            lr.Description = Description.Text;
            lr.SendDate = SendBy.DateTimeValue;
            lr.SendVia = SendVia.PickListValue;
            lr.Priority = Priority.PickListValue;
            lr.Options = PrintLiteratureList.SelectedIndex;

            lr.Save();

            Activity act = new Activity();
            act.Type = ActivityType.atLiterature;
            act.AccountId = lr.Contact.Account.Id.ToString();
            act.AccountName = lr.Contact.Account.AccountName;
            act.ContactId = lr.Contact.Id.ToString();
            act.ContactName = lr.ContactName;
            act.PhoneNumber = lr.Contact.WorkPhone;
            act.StartDate = (DateTime)lr.RequestDate;
            act.Duration = 0;
            act.Description = lr.Description;
            act.Alarm = false;
            act.Timeless = true;
            act.Rollover = false;
            act.UserId = lr.RequestUser.Id.ToString();
            act.OriginalDate = (DateTime)lr.RequestDate;
            act.Save();

            // save litRequest item
            double totalCost = 0.0;
            string coverId = arClientData[0];

            // get cover name
            for (int i = 1; i < arClientData.Length; i++)
            {
                string[] clientData = arClientData[i].Split('=');
                string litItemId = clientData[0];
                int qty = Int32.Parse(clientData[1]);

                // get literature item cost
                ILiteratureItem litItem = EntityFactory.GetById<ILiteratureItem>(litItemId);
                totalCost += (double)qty * (litItem.Cost.HasValue ? (double)litItem.Cost.Value : (double)0.0);

                // add the literature request item
                ILitRequestItem lrItem = EntityFactory.Create<ILitRequestItem>();
                lrItem.Qty = qty;
                lrItem.LitRequest = lr;
                lrItem.LiteratureItem = litItem;

                lr.LitRequestItems.Add(lrItem);
            }

            lr.TotalCost = totalCost;

            // get cover name
            string coverName = GetCoverName(coverId);
            lr.CoverName = coverName;

            lr.Save();  //must make ids match, and id prop is read only, so....

            SynchronizeLitRequestId(act.Id, lr.Id.ToString());

            // re-get entity with new activity id
            lr = EntityFactory.GetById<ILitRequest>(act.Id);

            // process the lit request if handle fulfillment locally is checked
            if (chkHandleLocal.Checked)
            {
                // show printer dialog for fulfillment
                FulfillRequestLocally(lr);

                // call business rule to update the entity properties
                lr.FulfillLitRequest();
            }
            else
            {
                Response.Redirect("Contact.aspx?entityId=" + lr.Contact.Id.ToString());
            }

        }
    }
开发者ID:ssommerfeldt,项目名称:TAC_CFX,代码行数:98,代码来源:LiteratureRequest.ascx.cs


注:本文中的Activity.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。