예제 #1
0
        static void Main(string[] args)
        {
            var execFunctions = new SPFunctions
            {
                { "deploy", options =>
                  {
                      Deploy.Demo(options.Context);
                      Deploy.ImportDemo(options.Context);
                  } }, { "demo", options =>
                         {
                             Deploy.ImportDemo(options.Context);
                         } }, { "retract", options =>
                                {
                                    Deploy.DemoRetractLite(options.Context);
                                } }
            };


            var forcePropmts = true;

            SharePoint.RunCSOM("--configPath='./configs/private.demo.json' --forcePrompts=" + forcePropmts, execFunctions);

            Console.WriteLine("Finished");
            Console.ReadKey();
        }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Exchange == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Exchange");
     }
     if (SharePoint == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "SharePoint");
     }
     if (Teams == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Teams");
     }
     if (Exchange != null)
     {
         Exchange.Validate();
     }
     if (SharePoint != null)
     {
         SharePoint.Validate();
     }
     if (Teams != null)
     {
         Teams.Validate();
     }
 }
        private void GetDocuments(string FolderPath)
        {
            SharePoint sp = new SharePoint();
            DataTable  dt = sp.GetDocuments(FolderPath);

            grdFiles.DataSource = dt;
            grdFiles.DataBind();
        }
예제 #4
0
 public static void Deploy(SPDeployOptions options)
 {
     SharePoint.Session(options.url, options.Credentials, ctx =>
     {
         var provisionService = new CSOMProvisionService();
         provisionService.DeployModel(SiteModelHost.FromClientContext(ctx), DeployModel());
     });
 }
예제 #5
0
 public static void Execute(SPDeployOptions options)
 {
     SharePoint.Session(options.url, options.Credentials, ctx =>
     {
         var Mask = new FieldMask(ctx);
         Mask.Execute();
     });
 }
예제 #6
0
 public static void ExecuteModel(this SiteModelNode Model, string url, ICredentials Credential = null)
 {
     SharePoint.Session(url, Credential, ctx =>
     {
         var provisionService = new CSOMProvisionService();
         provisionService.DeployModel(SiteModelHost.FromClientContext(ctx), Model);
     });
 }
예제 #7
0
        /// <summary>
        /// Creates the specified SharePoint using POST.
        /// </summary>
        /// <param name="sharePointToCreate">The SharePoint to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created SharePoint.</returns>
        public async System.Threading.Tasks.Task <SharePoint> CreateAsync(SharePoint sharePointToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <SharePoint>(sharePointToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        public async Task <ActionResult> SyncDocumentLibrary(string documentlibraryid)
        {
            try
            {
                if (documentlibraryid != null)
                {
                    Models.DocumentLibrary docLib = Repository.DocumentLibrary.Get(Convert.ToInt64(documentlibraryid));

                    // delete files from Azure
                    AzureBlobStorage azureStorage = new AzureBlobStorage();
                    string           error        = await azureStorage.DeleteDocumentLibraryDocumentsAsync(documentlibraryid, false);

                    // delete documents for this document library from db
                    List <Models.Document> documents = Repository.Documents.GetAllFromDocumentLibrary(Convert.ToInt64(documentlibraryid));

                    foreach (Document d in documents)
                    {
                        var retVal = Repository.Documents.Delete(d);
                    }

                    // download documents from SharePoint to Azure Storage... this might take a while if files are large in size or number
                    SharePoint      sp = new SharePoint();
                    List <Document> syncedDocuments = await sp.DownloadFilesToAzure(docLib);

                    // Save documents that were downloaded from SharePoint and saved to Azure Blob Storage to SQL db
                    foreach (Document d in syncedDocuments)
                    {
                        long docId = Repository.Documents.Save(d);
                    }

                    // return successful response
                    return(Json(new
                    {
                        Success = true,
                        DocumentLibraryId = Convert.ToInt64(documentlibraryid)
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    Success = false,
                    message = "An internal error occurred - please try again.  If this error persists, please contact your system administrator."
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                Success = false,
                message = "documentlibraryid is required."
            }, JsonRequestBehavior.AllowGet));
        }
예제 #9
0
        static void Main(string[] args)
        {
            SharePoint.CmdExecute(args, "SPF Image Field",
                                  options =>
            {
                Model.Deploy(options);
            },
                                  null,
                                  null
                                  );

            var t = "";
        }
예제 #10
0
        static void Main(string[] args)
        {
            SharePoint.CmdExecute(args, "SPF Newitem Callout",
                                  options =>
            {
                Model.Deploy(options);
            },
                                  null,
                                  null
                                  );

            var t = "";
        }
예제 #11
0
        static void Main(string[] args)
        {
            var fun = new SPFunctions()
            {
                { "artefacts", options =>
                  {
                      var l = "";
                  } },
                { "data", options =>
                  {
                      var l = "";
                  } },
                { "full", "KJNKJNKJN", options =>
                  {
                      var l = "";
                  } },
                { "divarts", "Description of divarts", options =>
                  {
                      options.EnsureCustomParam("Test4");

                      var MyCustomArg2 = options.LoadedSettings["custom"]["MyCustomArg2"];
                      var MyCustomArg5 = options.LoadedSettings["custom"]["MyCustomArg5"];
                      var l            = "";
                  } },
                { "divfields", options =>
                  {
                      var l = "";
                  } },
                { "divct", options =>
                  {
                      var l = "";
                  } },
                { "divlists", "Description of divlists", options =>
                  {
                      var l = "";
                  } },
                { "divquicklaunch", options =>
                  {
                      var l = "";
                  } },
                { "test_provision", options =>
                  {
                      var l = "";
                  } }
            };

            SharePoint.RunCSOM(string.Join(" ", args), fun);

            var t = "";
        }
예제 #12
0
        static void Main(string[] args)
        {
            SharePoint.CmdExecute(args, "SPF Extended settings for fields",
                                  options =>
            {
                Model.Deploy(options);
            },
                                  options =>
            {
                Model.Retract(options);
            },
                                  null
                                  );

            var t = "";
        }
예제 #13
0
 public static void Retract(SPDeployOptions options)
 {
     SharePoint.Session(options.url, options.Credentials, Ctx =>
     {
         var Site          = Ctx.Site;
         var CustomActions = Site.UserCustomActions;
         Ctx.Load(CustomActions);
         Ctx.ExecuteQuery();
         var SettingsLinkAction = CustomActions.Where(x => x.Name == SettingLink().Name).FirstOrDefault();
         if (SettingsLinkAction != null)
         {
             SettingsLinkAction.DeleteObject();
             Ctx.ExecuteQuery();
         }
     });
 }
        protected void btnDeleteDocument_Click(object sender, EventArgs e)
        {
            GridViewRow row    = (GridViewRow)((LinkButton)sender).NamingContainer;
            string      itemID = row.Cells[3].Text;

            SharePoint sp = new SharePoint();

            if (sp.DeleteDocument(itemID))
            {
                string path = "/" + txtFolder.Text;
                GetDocuments(path);
            }
            else
            {
                //Something is wrong
            }
        }
예제 #15
0
        private void GetViews()
        {
            if (cbSharePointLists.Text.Length > 0)
            {
                cbViews.Items.Clear();

                // Get view details (true)
                SharePoint.LoadListViewsFromSite(cbSharePointLists.Text, true);

                foreach (Data.ApplicationDS.dtViewsRow view in Common.ApplicationDS.dtViews)
                {
                    cbViews.Items.Add(view.DisplayName);
                    Common.WriteToDebugWindow(String.Format("DisplayName:{0}  ListName:{1}  Name:{2}  Query:{3}  Url:{4}",
                                                            view.DisplayName, view.ListName, view.Name, view.Query, view.Url));
                }
            }
        }
        public async Task <ActionResult> SaveDocumentLibrary(Models.DocumentsViewModel input)
        {
            try
            {
                if ((input != null) && (input.NewSPDocumentLibrary != null) && (TryValidateModel(input)) && (ModelState.IsValid))
                {
                    var docLib = input.NewSPDocumentLibrary;

                    // Save document library to db
                    docLib.DocumentLibraryId = Repository.DocumentLibrary.Save(docLib);

                    // Copy all documents from document library to Azure storage.. this may take a while if the files are large or there are many files...
                    SharePoint      sp        = new SharePoint();
                    List <Document> documents = await sp.DownloadFilesToAzure(docLib);

                    // Save documents that were downloaded from SharePoint and saved to Azure Blob Storage to SQL db
                    if (documents != null)
                    {
                        foreach (Document d in documents)
                        {
                            long docId = Repository.Documents.Save(d);
                        }
                    }
                    // Return successful response
                    return(Json(new
                    {
                        Success = true,
                        DocumentLibraryId = docLib.DocumentLibraryId
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    Success = false,
                    message = "An internal error occurred - please try again.  If this error persists, please contact your system administrator",
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                Success = false,
                message = "Doc lib was not saved - enter required values.",
            }, JsonRequestBehavior.AllowGet));
        }
        private bool UploadDocuments(string FolderPath)
        {
            bool success = false;

            if (fileRCA.HasFile)
            {
                foreach (var file in fileRCA.PostedFiles)
                {
                    SharePoint sp = new SharePoint();
                    success = sp.UploadDocument(file, FolderPath);
                }
            }
            else
            {
                // There isn't any files in the upload control.
            }

            return(success);
        }
예제 #18
0
        static void Main(string[] args)
        {
            var tasks = new SPFunctions()
            {
                {
                    "headers", options => {
                        WebHeaderCollection headers = ContextHeaders.GetHeaders(options.Context);

                        Console.WriteLine(headers.ToString());

                        var bp1 = ""; bp1 += ""; // Breakpoint
                    }
                }
            };

            SharePoint.Exec(args, tasks);

            var bp = ""; bp += ""; // Breakpoint
        }
예제 #19
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            // Was the app activated by a voice command?
            if (args.Kind == ActivationKind.VoiceCommand)
            {
                // Need to put this here to make sure the main page is displayed.
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame == null)
                {
                    rootFrame              = new Frame();
                    rootFrame.CacheSize    = 1;
                    Window.Current.Content = rootFrame;
                    rootFrame.Navigate(typeof(MainPage));
                }
                Window.Current.Activate();

                var commandArgs = args as VoiceCommandActivatedEventArgs;
                if (commandArgs != null)
                {
                    Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;

                    // What command was issued?
                    string voiceCommandName = speechRecognitionResult.RulePath[0];

                    if (voiceCommandName == "ShowMeAll")
                    {
                        // TODO - find a better way to access the list name from the phrase list.
                        // Get the name of the list the user wants.
                        string textSpoken = speechRecognitionResult.Text;
                        string listName   = textSpoken.Substring(textSpoken.LastIndexOf(" ", StringComparison.Ordinal)).Trim();

                        // Pull back the list items and display them on the UI
                        // TODO - need a better way to update the Main Page than this.
                        var announcements = await SharePoint.GetListItems(listName);

                        await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MainPage.Instance.UpdateListView(announcements));
                    }
                }
            }
        }
예제 #20
0
        static void Main(string[] args)
        {
            args = "--url https://snitko.sharepoint.com/sites/dev01/AutoTitle01 --execute --login [email protected] --password +Martezacker) --spo".Split(' ');
            //args = "--url http://republic.arvosys.com/test/Communications --deploy --login sergei.snitko --domain republic --password +Martezacker)".Split(' ');
            //args = "--url http://demo.arvosys.com/sites/city02/documents --execute --login spsql --domain cib --password 1qazxsw@".Split(' ');

            SharePoint.CmdExecute(args, "SPF AutoTitle Solution",
                                  options =>
            {
                Model.Deploy(options);
            },
                                  options =>
            {
                Model.Retract(options);
            },
                                  options =>
            {
                Model.Execute(options);
            }
                                  );

            var Stop = "";
        }
        // GET: api/Stores
        public HttpResponseMessage Get()
        {
            try
            {
                var listadoTiendas = new StoreCollection();
                using (var ctx = SharePoint.GetContext(userName, passWord, webURL))
                {
                    listadoTiendas.GetFromSharePoint(ctx);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, listadoTiendas));
            }
            catch (Exception ex)
            {
                var msg = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    Content    = new StringContent(ex.Message)
                };

                return(msg);
            }
        }
예제 #22
0
        static void Main(string[] args)
        {
            try
            {
                using (var ctx = SharePoint.GetContext(userName, passWord, webURL))
                {
                    var tienda = new Store()
                    {
                        Description = string.Format("Prueba de creación a las {0}", DateTime.Now.ToShortTimeString()),
                        Responsable = "*****@*****.**",
                        Provincia   = "España",
                        OpenDate    = DateTime.Now,
                        Tipo        = Store.TipoTienda.Franquicias
                    };

                    tienda.SaveInSharePoint(ctx);
                    Console.WriteLine("Tienda creada con ID: {0}", tienda.key);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred:{0}", ex.Message);
            }
        }
        public override void ExecuteCmdlet()
        {
            if (DataConnectorId == null)
            {
                DataConnectorId = Guid.NewGuid().ToString();
            }

            var name = DataConnectorId;

            var tenantId = AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id;

            if (ShouldProcess(name, VerbsCommon.New))
            {
                switch (ParameterSetName)
                {
                case ParameterSetNames.AzureActiveDirectory:
                    DataConnectorDataTypeCommon aadcommon = new DataConnectorDataTypeCommon
                    {
                        State = Alerts.ToLower()
                    };
                    AlertsDataTypeOfDataConnector aadalerts = new AlertsDataTypeOfDataConnector
                    {
                        Alerts = aadcommon
                    };
                    AADDataConnector aadDataTypes = new AADDataConnector
                    {
                        DataTypes = aadalerts,
                        TenantId  = tenantId
                    };
                    DataConnector aadDataConnector   = aadDataTypes;
                    var           outputaadconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, aadDataConnector);
                    WriteObject(outputaadconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.AzureAdvancedThreatProtection:
                    DataConnectorDataTypeCommon aatpcommon = new DataConnectorDataTypeCommon
                    {
                        State = Alerts.ToLower()
                    };
                    AlertsDataTypeOfDataConnector aatpalerts = new AlertsDataTypeOfDataConnector
                    {
                        Alerts = aatpcommon
                    };
                    AATPDataConnector aatpDataTypes = new AATPDataConnector
                    {
                        DataTypes = aatpalerts,
                        TenantId  = tenantId
                    };
                    DataConnector aatpDataConnector   = aatpDataTypes;
                    var           outputaatpconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, aatpDataConnector);
                    WriteObject(outputaatpconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.AzureSecurityCenter:
                    DataConnectorDataTypeCommon asccommon = new DataConnectorDataTypeCommon
                    {
                        State = Alerts.ToLower()
                    };
                    AlertsDataTypeOfDataConnector ascalerts = new AlertsDataTypeOfDataConnector
                    {
                        Alerts = asccommon
                    };
                    ASCDataConnector ascDataTypes = new ASCDataConnector
                    {
                        DataTypes      = ascalerts,
                        SubscriptionId = SubscriptionId
                    };
                    DataConnector ascDataConnector   = ascDataTypes;
                    var           outputascconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, ascDataConnector);
                    WriteObject(outputascconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.AmazonWebServicesCloudTrail:
                    AwsCloudTrailDataConnectorDataTypesLogs awscommon = new AwsCloudTrailDataConnectorDataTypesLogs
                    {
                        State = Logs.ToLower()
                    };
                    AwsCloudTrailDataConnectorDataTypes awslogs = new AwsCloudTrailDataConnectorDataTypes
                    {
                        Logs = awscommon
                    };
                    AwsCloudTrailDataConnector awsDataTypes = new AwsCloudTrailDataConnector
                    {
                        DataTypes  = awslogs,
                        AwsRoleArn = AwsRoleArn
                    };
                    DataConnector awsDataConnector   = awsDataTypes;
                    var           outputawsconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, awsDataConnector);
                    WriteObject(outputawsconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.MicrosoftCloudAppSecurity:
                    DataConnectorDataTypeCommon mcascommon = new DataConnectorDataTypeCommon
                    {
                        State = Alerts.ToLower()
                    };
                    DataConnectorDataTypeCommon mcasdiscovery = new DataConnectorDataTypeCommon
                    {
                        State = DiscoveryLogs
                    };
                    MCASDataConnectorDataTypes mcasDataTypes = new MCASDataConnectorDataTypes
                    {
                        Alerts        = mcascommon,
                        DiscoveryLogs = mcasdiscovery
                    };
                    MCASDataConnector mcasConnector = new MCASDataConnector
                    {
                        DataTypes = mcasDataTypes,
                        TenantId  = tenantId
                    };
                    DataConnector mcasDataConnector   = mcasConnector;
                    var           outputmcasconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, mcasDataConnector);
                    WriteObject(outputmcasconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.MicrosoftDefenderAdvancedThreatProtection:
                    DataConnectorDataTypeCommon mdatpcommon = new DataConnectorDataTypeCommon
                    {
                        State = Alerts.ToLower()
                    };
                    AlertsDataTypeOfDataConnector mdatpalerts = new AlertsDataTypeOfDataConnector
                    {
                        Alerts = mdatpcommon
                    };
                    MDATPDataConnector mdatpDataTypes = new MDATPDataConnector
                    {
                        DataTypes = mdatpalerts,
                        TenantId  = tenantId
                    };
                    DataConnector mdatpDataConnector   = mdatpDataTypes;
                    var           outputmdatpconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, mdatpDataConnector);
                    WriteObject(outputmdatpconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.Office365:
                    OfficeDataConnectorDataTypesExchange officeExchange = new OfficeDataConnectorDataTypesExchange
                    {
                        State = Exchange.ToLower()
                    };
                    OfficeDataConnectorDataTypesSharePoint officeSharePoint = new OfficeDataConnectorDataTypesSharePoint
                    {
                        State = SharePoint.ToLower()
                    };
                    OfficeDataConnectorDataTypesTeams officeTeams = new OfficeDataConnectorDataTypesTeams
                    {
                        State = Teams.ToLower()
                    };
                    OfficeDataConnectorDataTypes officeDataTypes = new OfficeDataConnectorDataTypes
                    {
                        Exchange   = officeExchange,
                        SharePoint = officeSharePoint,
                        Teams      = officeTeams
                    };
                    OfficeDataConnector officeConnector = new OfficeDataConnector
                    {
                        DataTypes = officeDataTypes,
                        TenantId  = tenantId
                    };
                    DataConnector officeDataConnector   = officeConnector;
                    var           outputofficeconnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, officeDataConnector);
                    WriteObject(outputofficeconnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                case ParameterSetNames.ThreatIntelligence:
                    TIDataConnectorDataTypesIndicators tiIndicators = new TIDataConnectorDataTypesIndicators
                    {
                        State = Indicators.ToLower()
                    };
                    TIDataConnectorDataTypes tiDataTypes = new TIDataConnectorDataTypes
                    {
                        Indicators = tiIndicators
                    };
                    TIDataConnector tiConnector = new TIDataConnector
                    {
                        DataTypes = tiDataTypes,
                        TenantId  = tenantId
                    };
                    DataConnector tiDataConnector   = tiConnector;
                    var           outputticonnector = SecurityInsightsClient.DataConnectors.CreateOrUpdate(ResourceGroupName, WorkspaceName, name, tiDataConnector);
                    WriteObject(outputticonnector.ConvertToPSType(), enumerateCollection: false);
                    break;

                default:
                    throw new PSInvalidOperationException();
                }
            }
        }
예제 #24
0
 /// <summary>
 /// Creates the specified SharePoint using POST.
 /// </summary>
 /// <param name="sharePointToCreate">The SharePoint to create.</param>
 /// <returns>The created SharePoint.</returns>
 public System.Threading.Tasks.Task <SharePoint> CreateAsync(SharePoint sharePointToCreate)
 {
     return(this.CreateAsync(sharePointToCreate, CancellationToken.None));
 }
예제 #25
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="sharePointToInitialize">The <see cref="SharePoint"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(SharePoint sharePointToInitialize)
 {
 }
예제 #26
0
        private async void GetListItems_OnClick(object sender, RoutedEventArgs e)
        {
            var announcements = await SharePoint.GetListItems("Announcements");

            UpdateListView(announcements);
        }
예제 #27
0
 private void btnGetSiteViews_Click_1(object sender, EventArgs e)
 {
     SharePoint.LoadViewsFromSite(false);
 }