示例#1
0
        public static void SharePointCSOM(this ExtendedOptions ExtendedOptions, Action <ClientContext> OnSuccess)
        {
            using (var clientContext = new ClientContext(ExtendedOptions.Options.SiteUrl))
            {
                Request.ApplyAuth <WebRequestEventArgs>(clientContext, ExtendedOptions.Options);

                OnSuccess(clientContext);
            }
        }
示例#2
0
 public static void EchoParams(ExtendedOptions Options)
 {
     //Console.Clear();
     //InlineParam("SharePoint URL", Options.Options.SiteUrl.ToString(), false);
     //Console.WriteLine();
     //InlineParam("Strategy", Options.Options.Strategy.ToString(), false);
     //// Console.WriteLine();
     //// InlineParam("User name", Options.LoadedSettings["username"].ToString(), false);
     //Console.WriteLine();
     //InlineParam(ExecuteParamsDescription, Options.LoadedSettings["custom"]["executeParams"].ToString(), false);
     //Console.WriteLine();
 }
示例#3
0
        public static void SharePointREST(this ExtendedOptions ExtendedOptions, string RequestUrl, Action <Stream> OnSuccess)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ExtendedOptions.Options.SiteUrl + RequestUrl);

            request.Accept = "application/json;odata=verbose";

            Request.ApplyAuth(request, ExtendedOptions.Options);

            using (HttpWebResponse spResponse = (HttpWebResponse)request.GetResponse())
            {
                using (Stream spResponseStream = spResponse.GetResponseStream())
                {
                    OnSuccess(spResponseStream);
                }
            }
        }
示例#4
0
        public static void ExecuteMappedFunctions(this ExtendedOptions ExtOptions, SPFunctions Functions)
        {
            string ExecuteParamsString = ExtOptions.LoadedSettings["custom"]["executeParams"].ToString();

            List <string> FunctionsToExecute = ExecuteParamsString.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();

            FunctionsToExecute.ForEach(FunctionName =>
            {
                var Function = Functions.Where(k => k.Key.ToLower() == FunctionName.ToLower()).FirstOrDefault();
                if (Function != null && Function.Void != null)
                {
                    Function.Void(ExtOptions);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("There is no function for key " + FunctionName);
                    Console.ResetColor();
                }
            });
        }
示例#5
0
        public static void EnsureCustomParam(this ExtendedOptions ExOptions, string ParamName)
        {
            var ConnectionOptions = ExOptions.Options;

            dynamic LoadedSettings   = Extentions.LoadSettings(ConnectionOptions.Settings.configPath);
            dynamic CustomProperties = LoadedSettings["custom"];

            // var forcePrompts = ConnectionOptions.Settings.forcePrompts;


            ParamName = ParamName.Replace("custom.", "");

            var CustomPropertiesDict = Extentions.ConvertExpandoToDict(CustomProperties);
            var CurrentValue         = "";

            if (!CustomPropertiesDict.ContainsKey(ParamName))
            {
                CustomProperties[ParamName] = Extentions.InlineParam(ParamName, CurrentValue);
            }

            Extentions.SaveSettings(LoadedSettings, ConnectionOptions.Settings.configPath);
            ExOptions.LoadedSettings = LoadedSettings;
        }
示例#6
0
        public static void GetParams(string args, Options ConnectionOptions, SPFunctions Functions, Action <ExtendedOptions> OnSuccess)
        {
            var tempArgs = Extentions.CommandLineParse(args);

            args = Extentions.CommandLineJoin(tempArgs);

            if (ConnectionOptions == null)
            {
                ConnectionOptions = SPAuth.GetAuth(args);
            }

            var saveConfigOnDisk = (bool)ConnectionOptions.Settings.saveConfigOnDisk;

            var ParsedArgs = Extentions.CommandLineParse(args.ModParams());

            var extoptions = new ExtendedOptions(ParsedArgs);

            extoptions.configPath = ConnectionOptions.Settings.configPath;
            extoptions.Options    = ConnectionOptions;
            dynamic LoadedSettings = saveConfigOnDisk ? Extentions.LoadSettings(extoptions.configPath) : JsonConvert.DeserializeObject <dynamic>("{}");

            if (LoadedSettings != null)
            {
                LoadedSettings = Extentions.AddExpandoProperty(LoadedSettings, "custom");
                var CustomProperties = Extentions.AddExpandoProperty(LoadedSettings["custom"], "executeParams", false);


                foreach (var ParsedArg in ParsedArgs)
                {
                    if (ParsedArg.Key.ToLower().IndexOf("custom.") != -1)
                    {
                        //CustomProperties.Add(ParsedArg.Key.Replace("custom.","").Trim(), ParsedArg.Value);
                        CustomProperties = Extentions.AddExpandoProperty(CustomProperties, ParsedArg.Key.Replace("custom.", "").Trim(), ParsedArg.Value);
                    }
                }
                LoadedSettings["custom"] = CustomProperties;

                extoptions.LoadedSettings = LoadedSettings;

                var ExecuteParams = CustomProperties["executeParams"];

                var forcePrompts = extoptions.forcePrompts || String.IsNullOrEmpty(ExecuteParams);
                if (forcePrompts)
                {
                    List <string> CustomPropertiesKeys = new List <string>(CustomProperties.Keys);

                    foreach (var CustomPropertyKey in CustomPropertiesKeys)
                    {
                        var Description = CustomPropertyKey;
                        if (CustomPropertyKey == "executeParams")
                        {
                            Description = Extentions.ExecuteParamsDescription;
                            CustomProperties[CustomPropertyKey] = Extentions.InlineMenu(Functions, Description, CustomProperties[CustomPropertyKey].ToString());
                        }
                        else
                        {
                            CustomProperties[CustomPropertyKey] = Extentions.InlineParam(Description, CustomProperties[CustomPropertyKey].ToString());
                        }
                    }
                }
                else
                {
                    Extentions.EchoParams(extoptions);
                }
                if (saveConfigOnDisk)
                {
                    Extentions.SaveSettings(LoadedSettings, extoptions.configPath);
                }

                OnSuccess(extoptions);
            }
        }