Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="service"></param>
 /// <param name="docType"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <param name="editText"></param>
 /// <param name="openControl"></param>
 /// <param name="delete"></param>
 public WebSiteDocItemModifier(SPService service, DocIconType docType, string key, string value, string editText, string openControl, bool delete)
     : base("DocIcon Modifier for " + key, service, null, SPJobLockType.None)
 {
     this._delete     = delete;
     this.Key         = key;
     this.Value       = value;
     this.EditText    = editText;
     this.OpenControl = openControl;
     this.docIconType = docType.ToString();
 }
        private void CreateJobs_DocIcons(DocIconType docType, string key, string value, string editText, string openControl, bool delete)
        {
            if (webApp != null)
            {
                string serviceName = "WSS_Administration";
                SPFarm farm        = SPFarm.Local;

                WebSiteDocItemModifier docJob = null;

                foreach (SPService service in farm.Services)
                {
                    if (service.Name == serviceName)
                    {
                        docJob = new WebSiteDocItemModifier(service, docType, key, value, editText, openControl, delete);

                        SPJobDefinition def = service.GetJobDefinitionByName(docJob.Name);
                        if (def != null)
                        {
                            def.Delete();
                        }

                        break;
                    }
                }

                docJob.Schedule = new SPOneTimeSchedule(DateTime.Now);
                docJob.Title    = string.Format("Modify {0} Icon for Mapping {1} in {2} section.", value, key, docType.ToString());
                docJob.Update();
                DateTime runtime;
                DateTime.TryParse(docJob.LastRunTime.ToString(), out runtime);
                while (runtime != null && (runtime == DateTime.MinValue || runtime == DateTime.MaxValue))
                {
                    DateTime.TryParse(docJob.LastRunTime.ToString(), out runtime);
                }
            }
        }