Beispiel #1
0
        public static bool CheckInItem(ISiteSetting siteSetting, IItem item, IConnectorExplorer connector)
        {
            CheckInForm checkInForm = new CheckInForm();

            checkInForm.Initialize(siteSetting, item);
            if (checkInForm.ShowDialog(null, Languages.Translate("Check In Item")) == true)
            {
                string          comment        = checkInForm.Comments;
                CheckinTypes    checkinType    = checkInForm.CheckInType;
                IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType);
                Result          result;
                if (result = serviceManager.CheckInFile(siteSetting, item, comment, checkinType))
                {
                    if (checkInForm.KeepDocumentCheckedOut == true)
                    {
                        serviceManager.CheckOutFile(siteSetting, item);
                    }
                    else
                    {
                        if (connector != null)
                        {
                            item.Properties["ows__Level"] = "1";
                            //connector.ContentExplorer.UpdateItem(item.GetID(), item);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(result.detailResult, result.messageResult, MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        public static void EditItemProperties(ISiteSetting siteSetting, object item, Folder folder)
        {
            IServiceManager    serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType);
            List <ContentType> contentTypes   = serviceManager.GetContentTypes(siteSetting, folder, false);//JD 6/8/13
            //list content types for this item
            List <ContentType> sigleContentTypes = new List <ContentType>();

            string webUrl;
            string listName;
            int    listItemID;
            string itemContentType;
            Dictionary <string, string> properties;

            if (item as SPFolder != null)
            {
                webUrl          = ((SPFolder)item).GetWebUrl();
                listName        = ((SPFolder)item).ListName;
                listItemID      = int.Parse(((SPFolder)item).ID);
                itemContentType = ((SPFolder)item).Properties["ContentTypeId"].ToString();
                properties      = ((SPFolder)item).Properties;
            }
            else
            {
                webUrl          = ((SPListItem)item).WebURL;
                listName        = ((SPListItem)item).ListName;
                listItemID      = ((SPListItem)item).ID;
                itemContentType = ((SPListItem)item).Properties["ContentTypeId"].ToString();
                properties      = ((SPListItem)item).Properties;
            }

            foreach (ContentType contentType in contentTypes)
            {
                if (contentType.Name.Equals(itemContentType) || contentType.ID.Equals(itemContentType))
                {
                    sigleContentTypes.Add(contentType);
                    break;
                }
            }



            EditItemPropertiesControl editControl = new EditItemPropertiesControl(folder.GetWebUrl(), null, sigleContentTypes, null, null, siteSetting, webUrl, properties, true);

            if (editControl.ShowDialog(null, Languages.Translate("Edit Properties")) == true)
            {
                ContentType contentType;
                Dictionary <object, object> values = editControl.GetValues(out contentType);
                serviceManager.UpdateListItem(siteSetting, webUrl, listName, listItemID, values, new Dictionary <string, object>());

                if (siteSetting.CheckInAfterEditProperties && editControl.requiredFieldsOk & (item as SPListItem != null))
                {
                    SPListItem   i         = ((SPListItem)item);
                    CheckinTypes checktype = siteSetting.useMajorVersionAsDefault ? CheckinTypes.MajorCheckIn : CheckinTypes.MinorCheckIn;
                    serviceManager.CheckInFile(siteSetting, (SPListItem)item, "", checktype);
                }
            }
        }
Beispiel #3
0
        public static void PasteItem(ISiteSetting siteSetting, object Item, Folder folder)
        {
            Folder f = folder;

            if (Item as SPListItem == null)
            {
                f = (Folder)Item;
            }

            FileCopyNameForm fileCopyNameForm = new FileCopyNameForm();

            fileCopyNameForm.Initialize(false, _CopiedItemInfo.Item.Title);
            bool needsTry = true;

            IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType);

            while (needsTry == true)
            {
                if (fileCopyNameForm.ShowDialog(null, Languages.Translate("File Name Confirmation"), 220, 400) == true)
                {
                    if (serviceManager.CheckItemCanBeCopied(siteSetting, folder, _CopiedItemInfo.Item, fileCopyNameForm.NewFileName) == true)
                    {
                        Result result =
                            serviceManager.CopyItem(siteSetting, folder, _CopiedItemInfo.Item, fileCopyNameForm.NewFileName);
                        needsTry = false;
                    }
                    else
                    {
                        fileCopyNameForm = new FileCopyNameForm();
                        fileCopyNameForm.Initialize(true, fileCopyNameForm.NewFileName);
                    }
                }
                else
                {
                    needsTry = false;
                }
            }

            if (_CopiedItemInfo.Move && true)
            {
                serviceManager.DeleteFile(siteSetting, _CopiedItemInfo.Item);
            }

            if (siteSetting.CheckInAfterCopy)
            {
                SPListItem item = new SPListItem(siteSetting.ID);
                item.WebURL = folder.GetWebUrl();
                item.URL    = folder.GetUrl().CombineUrl(fileCopyNameForm.NewFileName);
                CheckinTypes checktype = siteSetting.useMajorVersionAsDefault ? CheckinTypes.MajorCheckIn : CheckinTypes.MinorCheckIn;
                serviceManager.CheckInFile(siteSetting, item, "", checktype);
            }

            _CopiedItemInfo = null;
        }
Beispiel #4
0
        public static bool moveItem(ISiteSetting siteSetting, IItem item, Folder folder)
        {
            if (item == null)
            {
                return(false);
            }



            IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType);

            if (serviceManager.CheckItemCanBeCopied(siteSetting, folder, item, item.Title))
            {
                Result result = serviceManager.CopyItem(siteSetting, folder, item, item.Title);
                if (result.codeResult == "Success")
                {
                    serviceManager.DeleteFile(siteSetting, item);


                    if (siteSetting.CheckInAfterCopy)
                    {
                        SPListItem tempItem = new SPListItem(siteSetting.ID);
                        tempItem.WebURL = folder.GetWebUrl();
                        tempItem.URL    = folder.GetUrl().CombineUrl(item.Title);
                        CheckinTypes checktype = siteSetting.useMajorVersionAsDefault ? CheckinTypes.MajorCheckIn : CheckinTypes.MinorCheckIn;
                        serviceManager.CheckInFile(siteSetting, item, "", checktype);
                    }

                    return(true);
                }
            }
            else
            {
                MessageBox.Show(Languages.Translate("This object could not be move"), Languages.Translate("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            return(false);
        }
 public override void CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType)
 {
     ItemsManager.CheckInItem(siteSetting, item, this.ConnectorExplorer.ConnectorExplorer);
 }
        public Result CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType)
        {
            SPListItem         spLListItem = (SPListItem)item;
            ISharePointService spService   = new SharePointService();

            return(spService.CheckInFile(siteSetting, spLListItem.WebURL, spLListItem.URL, comment, checkinType));
        }
 public override void CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType)
 {
     throw new NotImplementedException();
 }
 public abstract void CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType);
Beispiel #9
0
 public Result CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType)
 {
     return(null);
 }
Beispiel #10
0
 public Result CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType)
 {
     throw new Exception("Not implemented yet");
 }