コード例 #1
0
        public void Insert2(Dictionary <string, object> dicList, string html, int menuID, string imgUri, string filename, string filePath)
        {
            if (NeedInsertDB)
            {
                string    sql1   = string.Format("select * from dbo.SchoolStyle where dbo.SchoolStyle.Description ='{0}'", dicList["Title"]);
                string    error1 = "";
                List <cm> cmList = DBManage.ExcuteEntity <cm>(sql1, System.Data.CommandType.Text, out error1);
                if (cmList.Count < 1)
                {
                    int modeType = 0;
                    if (dicList.ContainsKey("_x6a21__x7248_"))
                    {
                        if (dicList["_x6a21__x7248_"] != null)
                        {
                            modeType = 1;
                        }
                    }
                    Microsoft.SharePoint.Client.FieldUserValue vvv = dicList["Author"] as Microsoft.SharePoint.Client.FieldUserValue;
                    string creator = vvv.LookupValue;
                    html = html.Replace("'", "''");
                    string sql = string.Format("insert into SchoolStyle(MenuId,Title,[Description],CreateTime,ImageUrl,ClickNum,ModelType,IsDelete,Creator,FileName,FilePath)  values({0},'{1}','{2}','{3}','{4}',{5},{6},{7},'{8}','{9}','{10}')",
                                               menuID, dicList["Title"], html, dicList["Created"], imgUri, dicList["Count"], modeType, 0, creator, filename, filePath);
                    string error = "";

                    DBManage.Transaction(sql, out error);
                }
            }
        }
コード例 #2
0
        public static string GetDisplayValue(this SPClient.FieldUserValue value)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            return(string.Format("{0};#{1}", value.LookupId, value.LookupValue));
        }
コード例 #3
0
        private dynamic ChangeValue(dynamic value)
        {
            // Try and lookup object-based fields
            switch (value.ToString())
            {
            case "Microsoft.SharePoint.Client.FieldUserValue":

                SP.FieldUserValue uField = (SP.FieldUserValue)value;
                value = uField.LookupValue.ToString();

                break;

            case "Microsoft.SharePoint.Client.FieldLookupValue[]":

                value = null;

                break;
            }

            return(value);
        }
コード例 #4
0
        public object FromUser(bool allowMultipleValues, string users)
        {
            object value = null;

            if (!string.IsNullOrEmpty(users))
            {
                if (!allowMultipleValues)
                {
                    value = SP.FieldUserValue.FromUser(users.Trim(';'));
                }
                else
                {
                    var names      = users.Trim(';').Split(';');
                    var fieldValue = new SP.FieldUserValue[names.Count()];
                    for (int i = 0; i < names.Length; i++)
                    {
                        fieldValue[i] = SP.FieldUserValue.FromUser(names[i]);
                    }
                    value = fieldValue;
                }
            }
            return(value);
        }
コード例 #5
0
 public static Post QueryPostDetail(string postTitle, string category)
 {
     try
     {
         Post post = new Post();
         Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(string.Format(PostModel.postsSiteUrl, category), PostModel.postsListName, string.Format(PostModel.postDetailCamlQueryByTitle, postTitle));
         if (coll.Count > 0 && coll[0] != null)
         {
             SP.ListItem item = coll[0];
             post.Id = Convert.ToInt32(item["ID"]);
             SP.FieldUserValue author = (SP.FieldUserValue)item["Author"];
             post.Author        = author.LookupValue.ToString();
             post.Title         = postTitle;
             post.Body          = HLP.TransformHtmlStringForGlobalAsax(item["Body"].ToString());
             post.PublishedDate = Convert.ToDateTime(item["PublishedDate"]);
             post.CategoryName  = category;
         }
         return(post);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #6
0
        public void Insert(Dictionary <string, object> dicList, string html, int menuID, string imgUri, string filename, string filePath)
        {
            if (NeedInsertDB)
            {
                int modeType = 0;
                if (dicList.ContainsKey("_x6a21__x7248_"))
                {
                    if (dicList["_x6a21__x7248_"] != null)
                    {
                        modeType = 1;
                    }
                }


                Microsoft.SharePoint.Client.FieldUserValue vvv = dicList["Author"] as Microsoft.SharePoint.Client.FieldUserValue;
                string creator = vvv.LookupValue;
                html = html.Replace("'", "''");
                string sql = string.Format("insert into Advertising(MenuId,[Description], CreativeHTML,CreateTime,ImageUrl,ClickNum,ModelType,IsDelete,Creator,FileName,FilePath,isPush)  values({0},'{1}','{2}','{3}','{4}',{5},{6},{7},'{8}','{9}','{10}',{11})",
                                           menuID, dicList["Title"], html, dicList["Created"], imgUri, dicList["Count"], modeType, 0, creator, filename, filePath, 1);
                string error = "";

                DBManage.Transaction(sql, out error);
            }
        }
コード例 #7
0
        private void AddUsers(string siteName, string siteUrl, frm_Data_User userForm)
        {
            ClientContext clientContext = SharePoint.GetClient(siteUrl, frm_Main_Menu.username, frm_Main_Menu.password);

            Web web = clientContext.Web;

            // Instantiates the User Information List
            SP.List userList = web.SiteUserInfoList;

            // Get the current user
            SP.User user = web.CurrentUser;

            // Initialise row counter
            int rowNum = 0;

            // Create a new Caml Query
            CamlQuery camlQuery = new CamlQuery();

            // Set the XML
            camlQuery.ViewXml = "<View><Query>{0}</Query></View>";

            // Define a collection to store the list items in
            ListItemCollection collListItem = userList.GetItems(camlQuery);


            // Load in the items
            clientContext.Load(collListItem, icol => icol.Include(i => i.ContentType));
            clientContext.Load(collListItem);

            // Attempt to retreive the List Items
            try
            {
                clientContext.ExecuteQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            foreach (SP.ListItem oListItem in collListItem)
            {
                // Increment counter
                rowNum++;

                int id = (int)oListItem.FieldValues["ID"];

                object firstName  = oListItem.FieldValues["FirstName"];
                object lastName   = oListItem.FieldValues["LastName"];
                object fullName   = oListItem.FieldValues["Title"];
                object userName   = oListItem.FieldValues["UserName"];
                object email      = oListItem.FieldValues["EMail"];
                object sipAddress = oListItem.FieldValues["SipAddress"];

                object isSiteAdmin = oListItem.FieldValues["IsSiteAdmin"];
                object deleted     = oListItem.FieldValues["Deleted"];
                object hidden      = oListItem.FieldValues["UserInfoHidden"];
                object isActive    = oListItem.FieldValues["IsActive"];

                string ContentTypeName = oListItem.ContentType.Name;
                object guid            = oListItem.FieldValues["GUID"];

                DateTime          createDate = Convert.ToDateTime(oListItem.FieldValues["Created"]);
                SP.FieldUserValue author     = (SP.FieldUserValue)oListItem.FieldValues["Author"];
                string            createUser = author.LookupValue.ToString();

                DateTime          modifyDate = Convert.ToDateTime(oListItem.FieldValues["Modified"]);
                SP.FieldUserValue editor     = (SP.FieldUserValue)oListItem.FieldValues["Editor"];
                string            modifyUser = editor.LookupValue.ToString();

                if (firstName != null)
                {
                    //System.Diagnostics.Debugger.Break();
                }

                userForm.AddRow
                (
                    rowNum,
                    id,
                    firstName,
                    lastName,
                    fullName,
                    userName,
                    email,
                    sipAddress,
                    isSiteAdmin,
                    deleted,
                    hidden,
                    isActive,
                    ContentTypeName,
                    guid,
                    createDate,
                    createUser,
                    modifyDate,
                    modifyUser
                );

                lbl_Row_Count.Text = rowNum.ToString() + " record(s) found";
                lbl_Row_Count.Refresh();

                if (rowNum >= nud_Row_Limit.Value && nud_Row_Limit.Value != 0)
                {
                    break;
                }
            }
        }
コード例 #8
0
        public string InsertEmailSubjectSerial(string subject, string status, SubjectTopic subjectTopicValue, SubjectType subjectTypeValue, Microsoft.Office.Interop.Outlook.MailItem mailItem)
        {
            try
            {
                Guid   g       = Guid.NewGuid();
                string siteUrl = Properties.Settings.Default.ClientContextUrl;
                using (var clientContext = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, Properties.Settings.Default.ClientId, Properties.Settings.Default.ClientSecret))
                {
                    Web            oWebsite = clientContext.Web;
                    ListCollection collList = oWebsite.Lists;

                    SP.List oList = collList.GetByTitle("EmailSubject_Serial");
                    ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();

                    ListItem oListItem = oList.AddItem(itemCreateInfo);

                    // type section//////////////////////////////////////
                    FieldLookupValue typeFieldLookupValue = new FieldLookupValue();  //GetLookupFieldValue(subjectTypeValue.Title, "EmailSubject_Types");
                    typeFieldLookupValue.LookupId = subjectTypeValue.ID;
                    if (typeFieldLookupValue != null)
                    {
                        oListItem["ParentType"] = typeFieldLookupValue;
                    }
                    ////////////////////////////////////////////////////////////////
                    // tpoic section//////////////////////////////////////
                    FieldLookupValue topicFieldLookupValue = new FieldLookupValue();
                    topicFieldLookupValue.LookupId = subjectTopicValue.ID;
                    //FieldLookupValue topicFieldLookupValue = GetLookupFieldValue(subjectTopicValue.Title, "EmailSubject_Topics");
                    if (topicFieldLookupValue != null)
                    {
                        oListItem["ParentTopic"] = topicFieldLookupValue;
                    }
                    ////////////////////////////////////////////////////////////////
                    // status section//////////////////////////////////////
                    oListItem["Status"] = status; //Pending Comfirmed
                    ///////////////////////////////////////////////////////
                    // user section//////////////////////////////////////////
                    var usr = getEnsureUser(mailItem);
                    if (usr == null)
                    {
                        return("");
                    }

                    Microsoft.SharePoint.Client.FieldUserValue _userValue = new Microsoft.SharePoint.Client.FieldUserValue();
                    _userValue.LookupId = usr.Id;
                    oListItem["User"]   = _userValue;
                    ///////////////////////////////////////////////////////////////
                    // title section///////////////////////////////////////////////
                    oListItem["Title"] = g.ToString();
                    ////////////////////////////////////////////////////////////////
                    oListItem.Update();

                    clientContext.ExecuteQuery();

                    int id = oListItem.Id;

                    string subjectToReturn = "";
                    oListItem["Title"] = string.Format("[{0:D}-{1:D}-{2:D}] {3:D}", subjectTopicValue.Code, subjectTypeValue.Code, id, subject);
                    subjectToReturn    = string.Format("[{0:D}-{1:D}-{2:D}] {3:D}", subjectTopicValue.Code, subjectTypeValue.Code, id, subject);

                    oListItem.Update();

                    clientContext.ExecuteQuery();

                    return(subjectToReturn);
                }
            }
            catch (Exception ex)
            {
                return("");

                throw new Exception(ex.ToString());
            }
        }
コード例 #9
0
        public static bool EmailData(List <Employee> PendingEmployee, string siteUrl, string listName)
        {
            bool retValue = false;

            try
            {
                using (MSC.ClientContext context = CustomSharePointUtility.GetContext(siteUrl))
                {
                    //List<Mailing> varx = new List<Mailing>();

                    MSC.List list = context.Web.Lists.GetByTitle(listName);

                    MSC.ListItem listItem = null;

                    MSC.ListItemCreationInformation itemCreateInfo = new MSC.ListItemCreationInformation();
                    listItem = list.AddItem(itemCreateInfo);


                    // MSC.UserCollection users = new MSC.UserCollection();
                    //MSC.FieldUserValue fieldUserValue = new MSC.FieldUserValue();


                    MSC.FieldUserValue[] userValueCollection = new MSC.FieldUserValue[PendingEmployee.Count];
                    for (var i = 0; i < PendingEmployee.Count; i++)
                    {
                        MSC.FieldUserValue fieldUserVal = new MSC.FieldUserValue();
                        fieldUserVal.LookupId = Convert.ToInt32(PendingEmployee[i].EmployeeID);
                        userValueCollection.SetValue(fieldUserVal, i);
                    }


                    //var _From = "";
                    var _To = "";
                    //var _Cc = "";
                    var _Body    = "";
                    var _Subject = "";

                    _To = "1247";

                    _Subject = "Sales Estimate is not submitted";
                    _Body   += "Dear User, <br><br>This is to inform you that still your Sales Estimate is not submitted kindly fill and submit on priority.<br><br>Kindly click on below link for submit estimate";
                    _Body   += "<br><a href=" + siteUrl + "/SitePages/NewRequest.aspx>Submit Estimate</ a>";



                    listItem["ToUser"]      = userValueCollection;
                    listItem["SubjectDesc"] = _Subject;
                    listItem["BodyDesc"]    = _Body;
                    listItem.Update();


                    try
                    {
                        context.ExecuteQuery();
                        retValue = true;
                    }
                    catch (Exception ex)
                    {
                        CustomSharePointUtility.WriteLog(string.Format("Error in  InsertUpdate_EmployeeMaster ( context.ExecuteQuery();): Error ({0}) ", ex.Message));
                        return(false);
                        //continue;
                    }
                }

                //        }
                //    }
                //}

                //}
            }

            catch (Exception ex)
            {
                CustomSharePointUtility.WriteLog(string.Format("Error in  InsertUpdate_EmployeeMaster: Error ({0}) ", ex.Message));
            }
            return(retValue);
        }