コード例 #1
0
        public void Process(SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            SC.Data.Items.Item item = args.Item;

            if (item == null)
            {
                return;
            }

            if (SC.Context.IsAdministrator || CheckIn.CanCheckIn(item))
            {
                if (item.Locking.IsLocked() && (string.Compare(item.Locking.GetOwner(), SC.Context.User.Name, StringComparison.InvariantCultureIgnoreCase) != 0))
                {
                    SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                    warning.Title = SC.Globalization.Translate.Text("'{0}' has locked this item.", new object[] { item.Locking.GetOwnerWithoutDomain() });
                    warning.AddOption(SC.Globalization.Translate.Text("Check In"), string.Format("item:checkin(id={0},language={1},version={2})", item.ID, item.Language, item.Version.Number));
                }
            }
            else if (item.Locking.IsLocked())
            {
                if (!item.Locking.HasLock())
                {
                    args.Add(SC.Globalization.Translate.Text("You cannot edit this item because '{0}' has locked it.", new object[] { item.Locking.GetOwnerWithoutDomain() }), string.Empty);
                }
            }
            else if (SC.Configuration.Settings.RequireLockBeforeEditing && SC.Data.Managers.TemplateManager.IsFieldPartOfTemplate(SC.FieldIDs.Lock, item))
            {
                SC.Pipelines.GetContentEditorWarnings.GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add();
                warning.Title = SC.Globalization.Translate.Text("You must lock this item before you can edit it.");
                warning.Text  = SC.Globalization.Translate.Text("To lock this item, click Edit on the Home tab.");
                warning.AddOption(SC.Globalization.Translate.Text("Lock and Edit"), "item:checkout");
            }
        }
コード例 #2
0
        public override SC.Shell.Framework.Commands.CommandState QueryState(SC.Shell.Framework.Commands.CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            if (context.Items.Length != 1)
            {
                return(base.QueryState(context));
            }

            SC.Data.Items.Item item = context.Items[0];
            Assert.ArgumentNotNull(item, "context.Items[0]");

            if (SC.Context.IsAdministrator || !CheckIn.CanCheckIn(item))
            {
                return(base.QueryState(context));
            }

            if (!item.Locking.IsLocked())
            {
                return(SC.Shell.Framework.Commands.CommandState.Hidden);
            }

            if (CanCheckIn(item))
            {
                return(SC.Shell.Framework.Commands.CommandState.Enabled);
            }

            return(base.QueryState(context));
        }
コード例 #3
0
        /// <summary>
        /// Triggered at interval to determine whether to rebuild the index.
        /// </summary>
        /// <param name="args">Event arguments (not used by this implementation)</param>
        internal void Handle(EventArgs args)
        {
            Assert.IsNotNull(this._index, "_index");
            string path = "/sitecore/system/Settings/Rules/Indexing/Rebuilding/Rules";

            using (new SC.SecurityModel.SecurityDisabler())
            {
                SC.Data.Items.Item ruleRoot = this._ruleDatabase.GetItem(path);
                SC.Diagnostics.Assert.IsNotNull(
                    ruleRoot,
                    string.Format("ruleRoot item {0} in database {1}", path, this._ruleDatabase.Name));
                SC.Sharedsource.Rules.Indexing.IndexRebuildingRuleContext ruleContext =
                    new SC.Sharedsource.Rules.Indexing.IndexRebuildingRuleContext(this._index)
                {
                    IndexedDatabaseName = this._indexedDatabaseName,
                };

                SC.Rules.RuleList <SC.Sharedsource.Rules.Indexing.IndexRebuildingRuleContext> ruleList =
                    SC.Rules.RuleFactory.GetRules <SC.Sharedsource.Rules.Indexing.IndexRebuildingRuleContext>(ruleRoot.Axes.GetDescendants(), "Rule");
                Assert.IsNotNull(ruleList, "ruleList");
                Assert.IsTrue(
                    ruleList.Count > 0,
                    "ruleList.Count < 1 for " + path + " in database " + this._ruleDatabase.Name);
                ruleList.Run(ruleContext);

                if (ruleContext.ShouldRebuild)
                {
                    SC.ContentSearch.Diagnostics.CrawlingLog.Log.Info(
                        this + " : rebuild " + this._index.Name);
                    this._index.Rebuild();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Triggered by Sitecore to initialize the index rebuilding strategy.
        /// </summary>
        /// <param name="index">Index associated with the index rebuilding strategy.</param>
        public void Initialize(SC.ContentSearch.ISearchIndex index)
        {
            Assert.ArgumentNotNull(index, "index");

            if (this._ruleDatabase == null && !string.IsNullOrEmpty(index.Name))
            {
                string[] parts = index.Name.Split('_');

                if (parts.Length > 1)
                {
                    this._ruleDatabase = SC.Configuration.Factory.GetDatabase(parts[1]);
                }
            }

            SC.Diagnostics.Assert.IsNotNull(this._ruleDatabase, "_ruleDatabase");

            if (string.IsNullOrEmpty(this._indexedDatabaseName))
            {
                this._indexedDatabaseName = this._ruleDatabase.Name;
            }

            SC.ContentSearch.Diagnostics.CrawlingLog.Log.Info(string.Format(
                                                                  "[Index={0}] Initializing {1} with interval '{2}'.",
                                                                  index.Name,
                                                                  this.GetType().Name,
                                                                  this._alarmClock.Interval));
            this._index            = index;
            this._alarmClock.Ring += (sender, args) => this.Handle(args);
        }
コード例 #5
0
        public static bool HasUnlockAccess(SC.Data.Items.Item item, SC.Security.Accounts.User user = null)
        {
            Assert.ArgumentNotNull(item, "item");

            if (user == null)
            {
                user = SC.Context.User;
                Assert.IsNotNull(user, "context user");
            }

            if (user.IsAdministrator)
            {
                return(true);
            }

            SC.Security.AccessControl.AccessRight checkIn = SC.Security.AccessControl.AccessRight.FromName("item:checkin");

            if (checkIn != null)
            {
                return(SC.Security.AccessControl.AuthorizationManager.IsAllowed(item, checkIn, user));
            }

            SC.Security.Accounts.Role control = SC.Security.Accounts.Role.FromName("sitecore\\Sitecore Client Maintaining");

            return(SC.Security.Accounts.Role.Exists(control.Name) && SC.Security.Accounts.RolesInRolesManager.IsUserInRole(SC.Context.User, control, true /*includeIndirectMembership*/));
        }
コード例 #6
0
        /// <summary>
        /// Apply the rule.
        /// </summary>
        /// <param name="ruleContext">Rule processing context.</param>
        public override void Apply(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            Assert.ArgumentNotNull(ruleContext.Item, "ruleContext.Item");

            // for each language available in the item
            foreach (SC.Globalization.Language lang in ruleContext.Item.Languages)
            {
                SC.Data.Items.Item item = ruleContext.Item.Database.GetItem(
                    ruleContext.Item.ID,
                    lang);

                if (item == null)
                {
                    continue;
                }

                // to prevent the while loop from reaching MinVersions,
                // only process this number of items
                int limit = item.Versions.Count - this.MinVersions;
                int i     = 0;

                while (item.Versions.Count > this.MinVersions && i < limit)
                {
                    SC.Data.Items.Item version = item.Versions.GetVersions()[i++];
                    Assert.IsNotNull(version, "version");

                    if (this.MinUpdatedDays < 1 ||
                        version.Statistics.Updated.AddDays(this.MinUpdatedDays) < DateTime.Now)
                    {
                        this.HandleVersion(version);
                    }
                }
            }
        }
コード例 #7
0
        public ManagerResponse <CreateUserResult, CommerceUser> RegisterUserCustomer(IStorefrontContext storefrontContext, string userName, string password,
                                                                                     string email, string secondaryEmail)
        {
            Assert.ArgumentNotNull(storefrontContext, nameof(storefrontContext));
            Assert.ArgumentNotNullOrEmpty(userName, nameof(userName));
            Assert.ArgumentNotNullOrEmpty(password, nameof(password));
            CreateUserResult createUserResult1;

            try
            {
                var createUserRequest = new CreateUserRequest(userName, password, email, storefrontContext.CurrentStorefront.ShopName);
                createUserRequest.Properties.Add("SecondEmail", secondaryEmail);
                createUserResult1 = CustomerServiceProvider.CreateUser(createUserRequest);
                //createUserResult1 = CustomerServiceProvider.CreateUser(new CreateUserRequest(userName, password, email, storefrontContext.CurrentStorefront.ShopName));
                if (!createUserResult1.Success)
                {
                    Helpers.LogSystemMessages(createUserResult1.SystemMessages, createUserResult1);
                }
                else if (createUserResult1.Success)
                {
                    if (createUserResult1.CommerceUser == null)
                    {
                        if (createUserResult1.SystemMessages.Count == 0)
                        {
                            createUserResult1.Success = false;
                            createUserResult1.SystemMessages.Add(new SystemMessage()
                            {
                                Message = storefrontContext.GetSystemMessage("User Already Exists")
                            });
                        }
                    }
                }
            }
            catch (MembershipCreateUserException ex)
            {
                CreateUserResult createUserResult2 = new CreateUserResult {
                    Success = false
                };
                createUserResult1 = createUserResult2;
                createUserResult1.SystemMessages.Add(new SystemMessage()
                {
                    Message = ErrorCodeToString(storefrontContext, ex.StatusCode)
                });
            }
            catch (Exception ex)
            {
                CreateUserResult createUserResult2 = new CreateUserResult {
                    Success = false
                };
                createUserResult1 = createUserResult2;
                createUserResult1.SystemMessages.Add(new SystemMessage()
                {
                    Message = storefrontContext.GetSystemMessage("Unknown Membership Provider Error")
                });
            }
            CreateUserResult serviceProviderResult = createUserResult1;

            return(new ManagerResponse <CreateUserResult, CommerceUser>(serviceProviderResult, serviceProviderResult.CommerceUser));
        }
コード例 #8
0
        public override void Process(ServicePipelineArgs args)
        {
            ValidateArguments <CreateUserRequest, CreateUserResult>(args, out var request, out var result);
            Assert.IsNotNull(request.UserName, "request.UserName");
            Assert.IsNotNull(request.Password, "request.Password");
            Container container = GetContainer(request.Shop.Name, string.Empty, "", "", args.Request.CurrencyCode,
                                               new DateTime?());
            CommerceUser commerceUser1 = result.CommerceUser;

            if (commerceUser1 != null &&
                commerceUser1.UserName.Equals(request.UserName, StringComparison.OrdinalIgnoreCase))
            {
                string entityId = "Entity-Customer-" + request.UserName;
                ServiceProviderResult currentResult = new ServiceProviderResult();
                EntityView            entityView    = GetEntityView(container, entityId, string.Empty, "Details", string.Empty,
                                                                    currentResult);
                if (currentResult.Success && !string.IsNullOrEmpty(entityView.EntityId))
                {
                    base.Process(args);
                    return;
                }
            }

            EntityView entityView1 =
                GetEntityView(container, string.Empty, string.Empty, "Details", "AddCustomer", result);

            if (!result.Success)
            {
                return;
            }
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("Domain")).Value    = request.UserName.Split('\\')[0];
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("LoginName")).Value =
                request.UserName.Split('\\')[1];
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("AccountStatus")).Value = "ActiveAccount";
            if (!string.IsNullOrEmpty(request.Email))
            {
                entityView1.Properties.FirstOrDefault(p => p.Name.Equals("Email")).Value = request.Email;
            }
            CommerceCommand commerceCommand = DoAction(container, entityView1, result);

            if (commerceCommand != null &&
                commerceCommand.ResponseCode.Equals("ok", StringComparison.OrdinalIgnoreCase))
            {
                CommerceUser commerceUser2 = EntityFactory.Create <CommerceUser>("CommerceUser");
                commerceUser2.Email      = request.Email;
                commerceUser2.UserName   = request.UserName;
                commerceUser2.ExternalId = commerceCommand.Models.OfType <CustomerAdded>().FirstOrDefault()?.CustomerId;
                result.CommerceUser      = commerceUser2;
                request.Properties.Add(new PropertyItem()
                {
                    Key   = "UserId",
                    Value = result.CommerceUser.ExternalId
                });
                string entityId = "Entity-Customer-" + request.UserName;
                TestSave(container, entityId, request, result, commerceUser2.ExternalId);
            }

            base.Process(args);
        }
コード例 #9
0
 /// <summary>
 /// Rules engine condition implementation to determine if the name of an index
 /// contains a specific value.
 /// </summary>
 /// <param name="ruleContext">Rules processing context.</param>
 /// <returns>Returns true if the name of the index contains the specified value.</returns>
 protected override bool Execute(T ruleContext)
 {
     Assert.ArgumentNotNull(ruleContext, "ruleContext");
     Assert.ArgumentNotNull(ruleContext.IndexName, "ruleContext.IndexName)");
     Assert.ArgumentNotNullOrEmpty(this.MatchIndexNameAgainst, "MatchIndexNameAgainst");
     return(ruleContext.IndexName.ToLower().Contains(
                this.MatchIndexNameAgainst.ToLower()));
 }
コード例 #10
0
        /// <summary>
        /// Rules engine condition to determine whether the number of items updated
        /// since the last commit of changes to the search index to disk exceeds
        /// a given threshold.
        /// </summary>
        /// <param name="ruleContext">Rule processing context.</param>
        /// <returns>True if the number of indexed items updated since the last commit
        /// exceeds the given threshold.</returns>
        protected override bool Execute(T ruleContext)
        {
            Assert.IsTrue(this.Threshold > 0, "Threshold: " + this.Threshold);
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            bool result = ruleContext.UpdatesSinceLastCommit > this.Threshold;

            return(result);
        }
コード例 #11
0
        /// <summary>
        /// Rules engine condition to determine whether a given number
        /// of milliseconds has elapsed since the last commit of changes
        /// to a search engine to disk.
        /// </summary>
        /// <param name="ruleContext">Rule context type.</param>
        /// <returns>True if the number of milliseconds has updates </returns>
        protected override bool Execute(T ruleContext)
        {
            Assert.IsTrue(this.Threshold > 0, "Threshold: " + this.Threshold);
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            bool result = DateTime.Now.CompareTo(ruleContext.LastCommitted.AddMilliseconds(this.Threshold)) > 0;

            return(result);
        }
コード例 #12
0
 /// <summary>
 /// Rules engine condition implementation to determine whether a search index
 /// has been updated within the specified number of minutes.
 /// </summary>
 /// <param name="ruleContext">Rules processing context.</param>
 /// <returns>True if the index has not been updated
 /// within the specified number of minutes.</returns>
 protected override bool Execute(T ruleContext)
 {
     Assert.ArgumentNotNull(ruleContext, "ruleContext");
     Assert.ArgumentNotNull(this.CompareLastUpdatedAgainstMinutes, "CompareLastUpdatedAgainstMinutes");
     return(DateTime.Compare(
                ruleContext.LastUpdated.AddMinutes(this.CompareLastUpdatedAgainstMinutes.Value),
                DateTime.Now) < 0);
 }
コード例 #13
0
        protected override void Render(HtmlTextWriter writer)
        {
            string itemId = S.Web.WebUtil.GetQueryString("id");

            Assert.IsNotNullOrEmpty(itemId, "itemId");
            string dbName = S.Web.WebUtil.GetQueryString("database");

            Assert.IsNotNullOrEmpty(dbName, "dbName");
            S.Data.Database db = S.Configuration.Factory.GetDatabase(dbName);
            Assert.IsNotNull(db, "db: " + dbName);
            S.Data.Items.Item item = db.GetItem(itemId);
            Assert.IsNotNull(item, "item: " + itemId + " in " + dbName);
            string value = item["Type"];

            Assert.IsNotNullOrEmpty(value, "value: Type of " + item.Paths.FullPath);
            string name  = string.Empty;
            string dll   = string.Empty;
            int    comma = value.IndexOf(',');

            if (comma >= 0)
            {
                name = value.Substring(0, comma).Trim();
                dll  = value.Substring(comma + 1).Trim();
            }

            Assembly assembly = S.Reflection.ReflectionUtil.LoadAssembly(dll);

            Assert.IsNotNull(assembly, "assembly: " + dll);
            Type type = assembly.GetType(name, false, true);

            if (type == null)
            {
                type = assembly.GetType(name + "`1");
            }

            Assert.IsNotNull(type, "Type : " + name);
            dll = S.IO.FileUtil.MapPath("/bin/" + dll + ".dll");
            Assert.IsTrue(File.Exists(dll), "dll.Exists(): " + dll);
            string tempFile = string.Format(
                "{0}.{1}.il",
                type,
                DateTime.Now.ToString("yyyyMMddTHHmmssffff"));

            S.IO.TempFolder.EnsureFolder();
            tempFile = S.IO.FileUtil.MapPath(
                S.IO.FileUtil.MakePath(S.IO.TempFolder.Folder, tempFile, '/'));
            S.Sharedsource.Diagnostics.CommandLineTool clt =
                new S.Sharedsource.Diagnostics.CommandLineTool(
                    "c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.0A\\bin\\NETFX 4.0 Tools\\x64\\ildasm.exe");
            clt.Execute(
                true /*log*/,
                "/source /html /linenum /item=" + type + " /out=" + tempFile + " " + dll); // /pubonly
            Assert.IsTrue(File.Exists(tempFile), "tempFile.Exists(): " + tempFile);
            this.Response.Output.Write(S.IO.FileUtil.ReadFromFile(tempFile));
            this.Response.End();
            File.Delete(tempFile);
        }
コード例 #14
0
 /// <summary>
 /// Deletes the old version.
 /// </summary>
 /// <param name="version">The old version to delete.</param>
 public override void HandleVersion(SC.Data.Items.Item version)
 {
     Assert.ArgumentNotNull(version, "version");
     SC.Diagnostics.Log.Audit(
         this,
         "Delete version : {0}",
         new string[] { SC.Diagnostics.AuditFormatter.FormatItem(version) });
     version.Versions.RemoveVersion();
 }
        /// <summary>
        /// Implementation allows index rebuilding if the system minute
        /// is between StartMinute and EndMinute minutes since midnight, inclusive.
        /// </summary>
        /// <param name="ruleContext">Rule processing context.</param>
        /// <returns>True if this condition allows index rebuilding.</returns>
        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            Assert.ArgumentNotNull(this.StartMinute, "StartMinute");
            Assert.ArgumentNotNull(this.EndMinute, "EndMinute");
            DateTime now     = DateTime.Now;
            int      minutes = (now.Hour * 60) + now.Minute;

            return(minutes >= this.StartMinute.Value && minutes <= this.EndMinute.Value);
        }
コード例 #16
0
 /// <summary>
 /// Rules engine condition implementation to determine
 /// if the name of the database associated with an index
 /// matches a specific value.
 /// </summary>
 /// <param name="ruleContext">Rules processing context.</param>
 /// <returns>Returns true if the name of the database associated with the index
 /// matches the specified value.</returns>
 protected override bool Execute(T ruleContext)
 {
     Assert.ArgumentNotNull(ruleContext, "ruleContext");
     Assert.ArgumentNotNull(ruleContext.IndexedDatabaseName, "ruleContext.IndexedDatabaseName)");
     Assert.ArgumentNotNullOrEmpty(this.MatchIndexedDatabaseNameAgainst, "MatchIndexedDatabaseNameAgainst");
     return(string.Equals(
                ruleContext.IndexedDatabaseName,
                this.MatchIndexedDatabaseNameAgainst,
                StringComparison.InvariantCultureIgnoreCase));
 }
コード例 #17
0
ファイル: Edit.cs プロジェクト: bhaveshmaniya/Helixbase
        public override SC.Shell.Framework.Commands.CommandState QueryState(SC.Shell.Framework.Commands.CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            SC.Shell.Framework.Commands.CommandState state = base.QueryState(context);

            if (context.Items.Length == 1 && context.Items[0] != null && state == SC.Shell.Framework.Commands.CommandState.Disabled && CheckIn.CanCheckIn(context.Items[0]))
            {
                return(SC.Shell.Framework.Commands.CommandState.Enabled);
            }

            return(state);
        }
コード例 #18
0
        public override void DoProcess(
            SC.Sharedsource.Pipelines.GetPresentationDataSources.GetPresentationDataSourcesArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (!string.IsNullOrEmpty(args.RawDataSource))
            {
                return;
            }

            args.DataSourceItems.Add(SC.Context.Item);
        }
コード例 #19
0
        /// <summary>
        /// Gets the first item from the list of items matched by the query.
        /// </summary>
        /// <param name="assertMaxOne">Throw an exception if there is more than one
        /// item in the list.</param>
        /// <param name="assertMinOne">Throw an exception if there is less than one
        /// item in the list.</param>
        /// <returns>The first item in the list of items matched by the query.</returns>
        public SC.Data.Items.Item GetSingleItem(bool assertMaxOne, bool assertMinOne)
        {
            if (assertMaxOne)
            {
                Assert.IsFalse(this.Items.Length > 1, "this.Items.Length > 1");
            }

            if (assertMinOne)
            {
                Assert.IsFalse(this.Items.Length < 1, "this.Items.Length < 1");
            }

            return(this.Items[0]);
        }
コード例 #20
0
 public GetPresentationDataSourcesArgs(
     string dataSource,
     SC.Data.Items.Item contextItem,
     bool storeUISearchResults,
     bool storeSearchResultIDs,
     CS.IProviderSearchContext searchContext)
 {
     Assert.ArgumentNotNull(contextItem, "contextItem");
     this.RawDataSource        = dataSource;
     this.ContextItem          = contextItem;
     this.StoreUISearchResults = storeUISearchResults;
     this.StoreSearchResultIDs = storeSearchResultIDs;
     this.SearchContext        = searchContext;
 }
コード例 #21
0
 internal static void ValidateArguments <TRequest, TResult>(ServicePipelineArgs args, out TRequest request,
                                                            out TResult result) where TRequest : ServiceProviderRequest where TResult : ServiceProviderResult
 {
     Assert.ArgumentNotNull(args, nameof(args));
     Assert.ArgumentNotNull(args.Request, "args.Request");
     Assert.ArgumentNotNull(args.Request.RequestContext, "args.Request.RequestContext");
     Assert.ArgumentNotNull(args.Result, "args.Result");
     request = args.Request as TRequest;
     result  = args.Result as TResult;
     Assert.IsNotNull(request,
                      "The parameter args.Request was not of the expected type.  Expected {0}.  Actual {1}.",
                      typeof(TRequest).Name, args.Request.GetType().Name);
     Assert.IsNotNull(result,
                      "The parameter args.Result was not of the expected type.  Expected {0}.  Actual {1}.",
                      typeof(TResult).Name, args.Result.GetType().Name);
 }
コード例 #22
0
        public static bool CanCheckIn(SC.Data.Items.Item item, SC.Security.Accounts.User user = null)
        {
            Assert.ArgumentNotNull(item, "item");

            if (user == null)
            {
                user = SC.Context.User;
                Assert.IsNotNull(user, "context user");
            }

            if (item.Appearance.ReadOnly || !item.Locking.IsLocked() || !item.Access.CanWrite() || !item.Access.CanWriteLanguage())
            {
                return(false);
            }

            return(user.IsAdministrator ||
                   string.Compare(item.Locking.GetOwner(), user.Name, System.StringComparison.OrdinalIgnoreCase) == 0 ||
                   CheckIn.HasUnlockAccess(item));
        }
コード例 #23
0
        /// <summary>
        /// Archives the old version.
        /// </summary>
        /// <param name="version">The old version to archive.</param>
        public override void HandleVersion(SC.Data.Items.Item version)
        {
            Assert.ArgumentNotNull(version, "version");
            SC.Data.Archiving.Archive archive = version.Database.Archives["archive"];

            if (archive != null)
            {
                SC.Diagnostics.Log.Audit(
                    new object(),
                    "Archive version: {0}",
                    new string[] { SC.Diagnostics.AuditFormatter.FormatItem(version) });
                archive.ArchiveVersion(version);
            }
            else
            {
                SC.Diagnostics.Log.Audit(
                    this,
                    "Recycle version : {0}",
                    new string[] { SC.Diagnostics.AuditFormatter.FormatItem(version) });
                version.RecycleVersion();
            }
        }
コード例 #24
0
        protected void InvokeProcess(string arguments = null)
        {
            Assert.IsNotNullOrEmpty(this.CommandLine, "CommandLine");

            ProcessStartInfo procStartInfo = new ProcessStartInfo(this.CommandLine)
//      ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd")
            {
                WorkingDirectory       = S.Configuration.Settings.LogFolder,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            procStartInfo.UseShellExecute = false;

            //      procStartInfo.WindowStyle = ProcessWindowStyle.Normal;
            //      procStartInfo.LoadUserProfile = true;

//      procStartInfo.Arguments = "/c \"" + this.CommandLine + '"';

            if (!string.IsNullOrEmpty(arguments))
            {
                procStartInfo.Arguments = arguments;
//        procStartInfo.Arguments += " " + arguments;        procStartInfo.Arguments += " " + arguments;
            }

//      procStartInfo.CreateNoWindow = false;

            Process process = new Process {
                StartInfo = procStartInfo
            };

            Log.Info(this + " : invoke " + this.CommandLine + " " + procStartInfo.Arguments, this);
            process.Start();
            process.WaitForExit();
            this.ExitCode       = process.ExitCode;
            this.StandardError  = process.StandardError.ReadToEnd();
            this.StandardOutput = process.StandardOutput.ReadToEnd();
            process.Close();
        }
コード例 #25
0
        protected new void Run(SC.Web.UI.Sheer.ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (!SC.Web.UI.Sheer.SheerResponse.CheckModified())
            {
                return;
            }

            SC.Data.Items.Item item = SC.Client.GetItemNotNull(args.Parameters["id"], SC.Globalization.Language.Parse(args.Parameters["language"]), SC.Data.Version.Parse(args.Parameters["version"]));

            if (!(item.Locking.HasLock() || SC.Context.IsAdministrator || CheckIn.HasUnlockAccess(item)))
            {
                return;
            }

            SC.Diagnostics.Log.Audit(this, "Check in: {0}", new string[] { SC.Diagnostics.AuditFormatter.FormatItem(item) });

            using (new SC.Data.Items.EditContext(item, SC.SecurityModel.SecurityCheck.Disable))
                item.Locking.Unlock();

            SC.Context.ClientPage.SendMessage(this, "item:checkedin");
        }
        /// <summary>
        /// Empty implementation.
        /// </summary>
        /// <param name="searchIndex">Search index.</param>
        public void Initialize(CS.ISearchIndex searchIndex)
        {
            Assert.ArgumentNotNull(searchIndex, "searchIndex");
            Assert.ArgumentNotNullOrEmpty(searchIndex.Name, "searchIndex.Name");

            if (!string.IsNullOrEmpty(this.RuleDatabaseName))
            {
                return;
            }

            string[] parts = searchIndex.Name.Split('_');

            if (parts.Length < 2)
            {
                return;
            }

            if (SC.StringUtil.Contains(
                    parts[1],
                    SC.Configuration.Factory.GetDatabaseNames()))
            {
                this.RuleDatabaseName = parts[1];
            }
        }
コード例 #27
0
        // rewrite the Source property
        // set selectFirstItem now rather than parsing again later
        protected void ProcessSource(string originalSource)
        {
            if ((!string.IsNullOrEmpty(originalSource)) &&
                this.Source.Contains("{itemfield:"))
            {
                MatchCollection matches = Regex.Matches(
                    originalSource,
                    "(?<match>\\{itemfield\\:(?<field>[^\\}]+)})");
                Assert.IsTrue(matches.Count > 0, "matches > 0");

                foreach (Match match in matches)
                {
                    foreach (Group group in match.Groups)
                    {
                        originalSource = originalSource.Replace(
                            match.Groups["match"].Value,
                            this.CurrentItem[match.Groups["field"].Value]);
                    }
                }
            }

            // If the Source contains a single value, convert it to a
            // key=value pair.
            if (originalSource.StartsWith("query:") ||
                originalSource.StartsWith("~") ||
                originalSource.StartsWith("/") ||
                originalSource.StartsWith("."))
            {
                originalSource = "DataSource=" + originalSource;
            }

            SC.Collections.SafeDictionary <string> parameters =
                SC.Web.WebUtil.ParseQueryString(originalSource);
            string databaseName = parameters["DatabaseName"];

            if (String.IsNullOrEmpty(databaseName))
            {
                this.database = this.CurrentItem.Database;
            }
            else
            {
                this.database = SC.Configuration.Factory.GetDatabase(databaseName);
                SC.Diagnostics.Assert.IsNotNull(this.database, "database");
            }

            string dataSource = parameters["DataSource"];

            if (!(string.IsNullOrEmpty(dataSource) || dataSource.StartsWith("~")))
            {
                parameters["DataSource"] = this.ExpandDataSource(dataSource);
            }

            string sortBy = parameters["SortBy"];

            if (!string.IsNullOrEmpty(sortBy))
            {
                this.SortBy = sortBy;
                parameters.Remove("SortBy");
            }

            string display = parameters["Display"];

            if (!string.IsNullOrEmpty(display))
            {
                this.Display = display;
                parameters.Remove("Display");
            }

            string displayInTree = parameters["DisplayInTree"];

            if (displayInTree != null)
            {
                this.DisplayFieldName = displayInTree;
                parameters.Remove("DisplayInTree");
            }

            string includeItemsForDisplay = parameters["IncludeItemsForDisplay"];

            if ((!string.IsNullOrEmpty(includeItemsForDisplay) &&
                 includeItemsForDisplay.StartsWith("query:")))
            {
                parameters["IncludeItemsForDisplay"] =
                    this.CalculateIncludeItemsForDisplay(includeItemsForDisplay);
            }

            this.selectFirstItem = parameters["SelectFirstItem"];
            this.Source          = SC.Web.WebUtil.BuildQueryString(parameters, false);
        }
コード例 #28
0
ファイル: Edit.cs プロジェクト: bhaveshmaniya/Helixbase
 protected static new bool CanCheckIn(SC.Data.Items.Item item)
 {
     Assert.ArgumentNotNull(item, "item");
     return(CheckIn.CanCheckIn(item));
 }
コード例 #29
0
        /// <summary>
        /// Nested logic for argument processing and possible UI alerts.
        /// </summary>
        private void Apply(object[] parameters)
        {
            Assert.ArgumentCondition(
                parameters != null && parameters.Length == 1 && parameters[0] is ClientPipelineArgs,
                "parameters",
                "//TODO");
            ClientPipelineArgs args = parameters[0] as ClientPipelineArgs;

            // the FDA field of the item edited by the user
            Field field = this.Item.Fields[this.FieldID];

            Assert.IsNotNull(field, "field");

            FileDropAreaField fda = new FileDropAreaField(
                field,
                base.GetViewStateProperty("XmlValue", string.Empty) as string);
            ItemList mediaItems = fda.GetMediaItems();

            if (mediaItems.Count < 1)
            {
                SheerResponse.Alert(
                    Translate.Text("Add a media item."));
                args.AbortPipeline();
                return;
            }

            Item item = null;

            if (mediaItems.Count == 1)
            {
                item = mediaItems[0];
            }
            else if (mediaItems.Count > 1)
            {
                ItemList selectedItems = null;

                try
                {
                    // this may throw an exception; see 406891
                    selectedItems = this.GetSelectedItems();
                }
                catch (Exception ex)
                {
                    SheerResponse.Alert(
                        Translate.Text("Select an item from the list."));
                    args.AbortPipeline();
                    return;
                }

                if (selectedItems.Count != 1)
                {
                    SheerResponse.Alert(
                        Translate.Text("Select a single item from the list."));
                    args.AbortPipeline();
                    return;
                }

                item = selectedItems[0];
            }

            MediaItem mediaItem = new MediaItem(item);

            if (mediaItem.Extension != "docx")
            {
                SheerResponse.Alert(Translate.Text(
                                        "Seelect a Word document from the list."));
                args.AbortPipeline();
                return;
            }

            WordUtil.HandleWordDocument(this.Item, mediaItem);
        }
コード例 #30
0
 public CommitPolicyWrapper(SC.ContentSearch.ICommitPolicy policyToWrap)
 {
     Assert.ArgumentNotNull(policyToWrap, "policyToWrap");
     this._wrappedPolicy = policyToWrap;
 }