Exemplo n.º 1
0
        private static void WriteToSPList(SharePointListItem sPItem, SharePointConnection SPCon)
        {
            logger.log("Creating Sharepoint Item");
            using (ClientContext ctx = SPCon.SPOContext)
            {
                try
                {
                    logger.log($"working on {sPItem.Team}, {sPItem.Channel}, {sPItem.Thread}, {sPItem.Subject}, {sPItem.From}, {sPItem.Timestamp}, {sPItem.WebClientReadURL}, {sPItem.Message}");
                    List oList = SPCon.SPOContext.Web.GetListByTitle(SPCon.ListName);
                    ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
                    ListItem oListItem = oList.AddItem(itemCreateInfo);

                    oListItem["Title"]            = sPItem.Team;
                    oListItem["Channel"]          = sPItem.Channel;
                    oListItem["Thread"]           = sPItem.Thread;
                    oListItem["Subject"]          = sPItem.Subject;
                    oListItem["Editor"]           = ctx.Web.EnsureUser(sPItem.From);
                    oListItem["Modified"]         = DateTime.Parse(sPItem.Timestamp);
                    oListItem["WebClientReadURL"] = sPItem.WebClientReadURL;
                    oListItem["Message"]          = sPItem.Message;

                    oListItem.Update();
                    ctx.ExecuteQueryRetry();
                    logger.log("Creating Sharepoint Item sucessful");
                }
                catch (Exception e)
                {
                    logger.log("Creating Sharepoint Item Failed");
                    Console.WriteLine(e.Message);
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            logger.log("Got Request. Starting writing to list");

            if (args.Length == 0)
            {
                Console.WriteLine("syntax: exe /site:this /site: that");
            }
            else
            {
                SharePointConnection SPC = new SharePointConnection(args[8], args[9], args[10], args[11]);
                Worker.work(new SharePointListItem(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]), SPC);
            }
            logger.log("Got Request. Exiting writing to list");
        }
Exemplo n.º 3
0
 public static void work(SharePointListItem SPItem, SharePointConnection SPCon)
 {
     //we assume list exist, no checking done
     WriteToSPList(SPItem, SPCon);
 }