Ejemplo n.º 1
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                if (!IsValid)
                {
                    Script("resizeModalDialog('True');");
                }

                bool isUpdate = (IView == SPA.PageBase.ItemView.Edit);
                item = (isUpdate) ? new SPA.Web(ItemID) : new SPA.Web();

                string DatePreMigrated        = ((TextBox)this.dtcPreMigrate.Controls[0]).Text;
                string DateMigrated           = ((TextBox)this.dtcMigrate.Controls[0]).Text;
                string DateMigrationCompleted = ((TextBox)this.dtcMigrateCompleted.Controls[0]).Text;

                item.SPOSiteID       = int.Parse(hfSPOSiteeID.Value);
                item.HostNameID      = int.Parse(ddlHostName.SelectedValue);
                item.MigratorID      = int.Parse(hfUserID.Value);
                item.Migrate         = int.Parse(ddlMigrate.SelectedValue);
                item.RedirectEnabled = chkbxRedirectEnabled.Checked;

                DateTime preMigrate;
                if (String.IsNullOrWhiteSpace(DatePreMigrated))
                {
                    lblErrorMessage.Text += "null";
                    preMigrate            = new DateTime(1900, 1, 1);
                }
                else
                {
                    lblErrorMessage.Text += "not null";
                    preMigrate            = Convert.ToDateTime(DatePreMigrated);
                }
                item.PreMigrateOn = preMigrate;

                DateTime migrate;
                if (String.IsNullOrWhiteSpace(DateMigrated))
                {
                    lblErrorMessage.Text += "null";
                    migrate = new DateTime(1900, 1, 1);
                }
                else
                {
                    lblErrorMessage.Text += "not null";
                    migrate = Convert.ToDateTime(DateMigrated);
                }
                item.MigrateOn = migrate;

                DateTime completed;
                if (String.IsNullOrWhiteSpace(DateMigrationCompleted))
                {
                    lblErrorMessage.Text += "null";
                    completed             = new DateTime(1900, 1, 1);
                }
                else
                {
                    lblErrorMessage.Text += "not null";
                    completed             = Convert.ToDateTime(DateMigrationCompleted);
                }
                item.MigrationCompleted = completed;


                item.ModifiedBy = CurrentUser.DisplayName;

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }