private static void MoveThumbNail(DBM db) { ClientContext ctx = new ClientContext("http://sp13devwfe01:8623/leadersconnect/leadersconnect/"); Web oSourceWeb = ctx.Web; ctx.Load(oSourceWeb); ctx.ExecuteQuery(); foreach (DataRow dr in db.getRecordForLeadersConnectThumbNail().Rows) { string filePath = dr["DownloadPath"].ToString(); FileInfo temp = new FileInfo(filePath); using (var fs = new FileStream(filePath, FileMode.Open)) { List oDocumentList = null; if (dr["Type"].ToString().ToLower() == "t") { oDocumentList = ctx.Web.Lists.GetByTitle("TextBlogsImages"); } else { oDocumentList = ctx.Web.Lists.GetByTitle("VideoThumbnails"); } ctx.Load(oDocumentList.RootFolder); ctx.ExecuteQuery(); var fileUrl = String.Format("{0}/{1}", oDocumentList.RootFolder.ServerRelativeUrl, System.Web.HttpUtility.UrlDecode(temp.Name.Substring(temp.Name.IndexOf("_") + 1))); Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, fileUrl, fs, true); } } }
static private string GetList <T>(DBM dbm, string storeName, Hashtable htParams, out List <T> list) { string msg = ""; list = null; DataTable dt = null; if (dbm == null) { msg = ExecStore(ConnectionString, storeName, htParams, out dt); } else { msg = dbm.ExecStore(out dt); } if (msg.Length > 0) { return(msg); } msg = DataTableToList(dt, out list); return(msg); }
public JsonResult UnVote(int answerId = 0) { int userId = GetUserId(); DBM.ExecStore("sp_VoteAnswer_UnVote", new { AnswerId = answerId, UserId = userId, UserName = GetUserName() }, out int countLike); return(Json(countLike, JsonRequestBehavior.AllowGet)); }
public JsonResult DisLike(int askId = 0) { int userId = GetUserId(); DBM.ExecStore("sp_AskLike_DisLike", new { AskId = askId, UserId = userId, UserName = GetUserName() }, out int countLike); return(Json(countLike, JsonRequestBehavior.AllowGet)); }
static private string GetOne <T>(DBM dbm, string storeName, Hashtable htParams, out T oneItem) { oneItem = default(T); List <T> list = null; string msg = GetList(dbm, storeName, htParams, out list); if (msg.Length > 0) { return(msg); } if (list == null) { return("Error: list is null @DBM.GetOne"); } if (list.Count == 0) { return(""); } oneItem = list[0]; return(msg); }
public JsonResult CheckLogin(string userName, string password) { //Mã hóa password string passwordHash = ""; //Mã hóa MD5 cho password using (MD5 md5Hash = MD5.Create()) { passwordHash = GetMd5Hash(md5Hash, password); } //Mang vào CSDL kiểm tra thông tin đăng nhập DBM.GetOne("sp_User_Login", new { UserName = userName, PasswordHash = passwordHash }, out UserModel userModel); //Lưu Cookie cho những lần truy cập sau //Kiểm tra nếu đăng nhập thành công thì Lưu Cookie if (userModel != null) { //Lưu Cookie HttpCookie userInfo = new HttpCookie("UserLogin")//UserLogin: Tên Cookie { ["UserId"] = userModel.UserId.ToString(), ["UserName"] = userModel.UserName, ["FullName"] = userModel.FullName, ["RoleId"] = userModel.RoleId.ToString(), ["Email"] = userModel.Email.ToString() }; //Lưu 30 ngày userInfo.Expires.AddDays(30); Response.Cookies.Add(userInfo); } return(Json(userModel, JsonRequestBehavior.AllowGet)); }
public ActionResult AskDetail(int askId) { DBM.GetOne("sp_Ask_Detail", new { AskId = askId }, out AskModel askModel); askModel.IsLogin = IsLogin(); askModel.IsBoss = askModel.UserId == GetUserId() ? true : false; return(View(askModel)); }
// GET: Customer public ActionResult Index() { using (DBM db = new DBM()) { return(View(db.Customer.Tolist())); } }
// GET: Current_order/Edit/5 public ActionResult Edit(int id) { using (DBM db = new DBM()) { return(View(db.Current_order.Where(x => x.O_M_id == id).FirstOrDefault())); } }
public JsonResult UnConfirm(int askId, int answerId) { int userId = GetUserId(); DBM.ExecStore("sp_Answer_UnConfirmAnswer", new { AnswerId = answerId, AskId = askId, UserId = userId }); return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult Index(string alias) { int categoryId = 0; if (!string.IsNullOrEmpty(alias))//Trả về true khi alias rỗng { DBM.GetOne("sp_Category_FillByAlias", new { Alias = alias }, out CategoryModel categoryModel); if (categoryModel != null) { categoryId = categoryModel.CategoryId; } } DBM.ExecStore("sp_Ask_Count", new { CategoryId = categoryId }, out int totalRow); //Đếm xem có bao nhiêu trang int totalPage = (int)Math.Ceiling((double)totalRow / pageSize); DBM.GetList("sp_Ask_GetPaging", new { CategoryId = categoryId, Page = 1, PageSize = pageSize }, out List <AskModel> askViewModels); PaginationObject <List <AskModel> > pagination = new PaginationObject <List <AskModel> > { Page = 1, TotalPages = totalPage, TotalRow = totalRow, PageSize = pageSize, ObjectFilter = askViewModels }; return(View("Index", pagination)); }
// GET: Customer/Delete/5 public ActionResult Delete(int id) { using (DBM db = new DBM()) { return(View(db.Customer.Where(x => x.Customer_id == id).FirstOrDefault())); } }
public ActionResult EditAsk(int askId) { DBM.GetList("sp_Category_GetAll", new { }, out List <CategoryModel> categoryModels); DBM.GetOne("sp_Ask_Detail", new { AskId = askId }, out AskModel askModel); askModel.CategoryModels = categoryModels; return(View(askModel)); }
static void Main(string[] args) { DBM db = new DBM(); string url = "http://sp13devwfe01:8623/Hydrocarbon/FCNA"; ClientContext ctx = new ClientContext(url); Web oWeb = ctx.Web; ctx.Load(oWeb); ctx.ExecuteQuery(); foreach (DataRow dr in db.getRecordForActivity().Rows) { int blogid = (int)dr["BlogID"]; string activity = dr["Activity"].ToString(); Console.WriteLine(blogid); ListItem oItem = oWeb.Lists.GetByTitle("DiscussionText").GetItemById(blogid); //ListItem oItem = oWeb.Lists.GetByTitle("Discussions List").GetItemById(blogid); ctx.Load(oItem); List lookuplist = ctx.Web.Lists.GetByTitle("Activity"); oItem["Activity"] = GetLookFieldIDS(ctx, activity, lookuplist); // oItem["Activity"] = lv; oItem.Update(); ctx.ExecuteQuery(); } }
public JsonResult RegisterUser(UserModel userModel) { string passwordHash = ""; //Mã hóa MD5 cho password using (MD5 md5Hash = MD5.Create()) { passwordHash = GetMd5Hash(md5Hash, userModel.PasswordHash); } DBM.ExecStore("sp_User_Register", new { userModel.UserName, userModel.FullName, PasswordHash = passwordHash, userModel.Phone, userModel.Email }, out int isExists); if (isExists == 0) { return(Json("Tên đăng nhập đã tồn tại!", JsonRequestBehavior.AllowGet)); } else { return(Json("", JsonRequestBehavior.AllowGet)); } }
public JsonResult Add(AnswerModel answerModel) { int userId = GetUserId(); DBM.ExecStore("sp_Answer_Insert", new { answerModel.AskId, UserId = userId, answerModel.AnswerContent }); return(Json("", JsonRequestBehavior.AllowGet)); }
// GET: Current_order public ActionResult Index() { using (DBM db = new DBM()) { return(View(db.Current_order.ToList())); } }
private static string getBlogDetails(ClientContext ctx, Web w, string type, DBM db, TypeOfContent content) { ListCollection lsts = w.Lists; //For every type of dicussion title foreach (string btype in blogtype) { ctx.Load(lsts, lst => lst.Include(ls => ls.Title).Where(ls => ls.Title == btype)); ctx.ExecuteQuery(); if (lsts.Count > 0) { ctx.Load(w); ctx.Load(w.ParentWeb); List l = w.Lists.GetByTitle(btype); ctx.Load(l); ctx.ExecuteQuery(); string ParentTitle = string.Empty; string CurrentTitle = string.Empty; if (type.ToLower() != "root") { ParentTitle = w.ParentWeb.Title.Replace("'", "''"); } CurrentTitle = w.Title.Replace("'", "''"); if (content == TypeOfContent.Defination) { GetListDefination(ctx, l, type, ParentTitle, CurrentTitle); if (CurrentTitle.ToLower() == "learnet") { if (Array.FindIndex(blogtype, bt => bt == btype) == blogtype.Length - 1) { db.udpateSiteMigratedStatus(ctx.Web.Url, "LDEFM"); } } else { db.udpateSiteMigratedStatus(ctx.Web.Url, "LDEFM"); } } else if (content == TypeOfContent.DataItem) { GetListItem(ctx, l, btype, ParentTitle, CurrentTitle); if (CurrentTitle.ToLower() == "learnet") { if (Array.FindIndex(blogtype, bt => bt == btype) == blogtype.Length - 1) { db.udpateSiteMigratedStatus(ctx.Web.Url, "LDATAM"); } } else { db.udpateSiteMigratedStatus(ctx.Web.Url, "LDATAM"); } } // return l.ItemCount.ToString(); } } return("0"); }
private static void GetListItem(ClientContext ctx, List oBlog, string typeofBlog, string ParentTitle, string CurrentTitle) { CamlQuery varQuery = new CamlQuery(); if (CurrentTitle.ToLower() == "learnet") { varQuery.ViewXml = getQueryForCollection((oBlog.Title.ToLower() == "discussions list" ? CurrentTitle + "video" : CurrentTitle + "text")); //varQuery.ViewXml = getQueryForCollection(CurrentTitle); } else { varQuery.ViewXml = getQueryForCollection(CurrentTitle); } ListItemCollection lstitemcol = oBlog.GetItems(varQuery); ctx.Load(lstitemcol); ctx.ExecuteQuery(); DBM db = new DBM(); DataTable dt = null; dt = db.getListDefination(ParentTitle, CurrentTitle, oBlog.Title); foreach (ListItem item in lstitemcol) { //if (item["ID"].ToString() == "1798") //{ ManageItemData(ctx, db, dt, item, "parent"); #region "Migrating Comment" //Get the Comments for Discussion Blog if (typeofBlog.ToLower() != "posts") { CamlQuery q = new CamlQuery(); //Find all replies for topic with ID=1 q.ViewXml = @"<View Scope='Recursive'> <Query> <Where> <Eq> <FieldRef Name=""ParentFolderId"" /> <Value Type=""Integer"">" + item["ID"] + "</Value></Eq></Where></Query></View>"; ListItemCollection replies = item.ParentList.GetItems(q); ctx.Load(replies); ctx.ExecuteQuery(); Console.WriteLine(replies.Count); foreach (ListItem i in replies) { ManageItemData(ctx, db, dt, i, "reply"); } } else { GetListDataComment(ctx, item, dt.Rows[0][0].ToString(), db); } #endregion //} } }
public JsonResult Update(AskModel askModel) { string slugUrl = askModel.Content.Length > 100 ? askModel.Content.Substring(0, 100).ToSlugUrl() : askModel.Content.ToSlugUrl(); DBM.GetOne("sp_Ask_Update", new { askModel.AskId, askModel.Content, askModel.CategoryId, UserId = askModel.UserId, SlugUrl = slugUrl }, out AskModel askModel1); return(Json(askModel1, JsonRequestBehavior.AllowGet)); }
static void Main(string[] args) { DBM db = new DBM(); UpDatecOMMENTINDB(db); //string url = "http://sp13devwfe01:46809/Hydrocarbon/ENP"; //ClientContext ctx = new ClientContext(url); // Web oWeb = ctx.Web; //ctx.Load(oWeb); //ctx.ExecuteQuery(); // UpDateKeyArea(db.getRecordForActivity()); //StringBuilder strInsert = new StringBuilder(); //foreach(DataRow dr in db.getRecordForKEYAREACT().Rows) //{ // string query = "Insert into Abc (SC,Type,ID,CommentCount) values ({0},{1},{2},{3})"; // string url = "http://digitalj3.ril.com/{0}/{1}"; // url = "http://digitalj3.ril.com"; // ClientContext ctx = new ClientContext(string.Format(url, dr["Segment"].ToString(), dr["Channel"].ToString())); // Web oWeb = ctx.Web; // ctx.Load(oWeb); // ctx.ExecuteQuery(); // int blogid =(int) dr["BlogID"]; // // int keyarea = Convert.ToInt16( dr["KeyArea"].ToString()); // DateTime approvedDate = Convert.ToDateTime(dr["Created"].ToString()); // Console.WriteLine( blogid); // // int ct = Convert.ToInt16((dr["ContenTypeId"].ToString() == "" ? "0" : dr["ContenTypeId"].ToString())); // //ListItem oItem= oWeb.Lists.GetByTitle("DiscussionText").GetItemById(blogid); // ListItem oItem = null;// oWeb.Lists.GetByTitle("Discussions List").GetItemById(blogid); // if (dr["Type"].ToString().ToLower() == "t") // { // // oItem = oWeb.Lists.GetByTitle("DiscussionText").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); // oItem = oWeb.Lists.GetByTitle("MyCorner").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); // } // else // { // oItem = oWeb.Lists.GetByTitle("Discussions List").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); // } // ctx.Load(oItem); // ctx.ExecuteQuery(); // strInsert.AppendLine(string.Format(query, dr["Segment_Channel_ID"], dr["Type"].ToString(), dr["BlogID"].ToString(), oItem["TotalCommentCount"].ToString())); // ////oItem["KeyAreas"] = keyarea; // ////if (ct != 0) // ////{ // //// oItem["ContenTypeId"] = 6;// ct; // ////} // //oItem["ApprovedDate"] = approvedDate; // //oItem.Update(); // //ctx.ExecuteQuery(); //} }
static void Main(string[] args) { Console.Title = "LeadersConnect"; DBM db = new DBM(); ClientContext ctx = null; List <Blog> blogUploadCollection = db.getRecordForLeadersConnect(); foreach (Blog b in blogUploadCollection) { bool rootSite = false; string url = "http://sp13devwfe01:8623/{0}/{1}"; if (b.siteCollection.ToLower() == "root") { url = "http://sp13devwfe01:8623"; rootSite = true; } Console.WriteLine(string.Format(url, b.siteCollection, b.subSite)); Console.WriteLine(string.Format("{0} {1} {2}", b.siteCollection, b.subSite, b.ID)); ctx = new ClientContext(string.Format(url, b.siteCollection, b.subSite)); Web oWeb = ctx.Web; ctx.Load(oWeb); ctx.ExecuteQuery(); ListItem oItem = null; if (b.typeOfContent.ToLower() == "t") { if (rootSite) { oItem = oWeb.Lists.GetByTitle("MyCorner").GetItemById(Convert.ToInt32(b.ID)); } else { oItem = oWeb.Lists.GetByTitle("DiscussionText").GetItemById(Convert.ToInt32(b.ID)); } } else { oItem = oWeb.Lists.GetByTitle("Discussions List").GetItemById(Convert.ToInt32(b.ID)); } ctx.Load(oItem); ctx.ExecuteQuery(); b.body = oItem["Body"].ToString(); if (b.typeOfContent.ToLower() == "v") { b.filepath = oItem["FileName"].ToString(); } //Add ListItem AddItem(db, b, oItem); } MoveThumbNail(db); Console.ReadKey(); }
static void Main(string[] args) { DBM db = new DBM(); Console.Title = "Remove Blog"; //DataTable dt = db.getRecordForHide(); // DataTable dt = db.getRecordForDataMovedtoMyCornerFromFCNA(); DataTable dt = db.getRecordForDummyData(); string blogID = string.Empty; foreach (DataRow dr in dt.Rows) { string url = "http://sp13devwfe01:46809/{0}/{1}"; if (dr["Segment"].ToString().ToLower() == "root") { url = "http://sp13devwfe01:46809"; } Console.WriteLine(Convert.ToInt32(dr["BlogID"].ToString())); ClientContext ctx = new ClientContext(string.Format(url, dr["Segment"].ToString(), dr["Channel"].ToString())); Web oWeb = ctx.Web; ctx.Load(oWeb); ctx.ExecuteQuery(); ListItem lst = null; if (dr["Type"].ToString().Trim().ToLower() == "t") { if (dr["Segment"].ToString().ToLower() != "root") { lst = oWeb.Lists.GetByTitle("DiscussionText").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); } else { lst = oWeb.Lists.GetByTitle("MyCorner").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); } } else { lst = oWeb.Lists.GetByTitle("Discussions List").GetItemById(Convert.ToInt32(dr["BlogID"].ToString())); } ctx.Load(lst); try { ctx.ExecuteQuery(); rollbackTransaction(lst, ctx, "Hide Need to Removed", Convert.ToInt32(dr["DBID"].ToString()), ref db, dr); } catch (Exception) { // blogID += dr["BlogDetailAlphaNumber"].ToString() + "','"; } } }
public string Insert() { string msg = DBM.GetOne("usp_UserRegisterOTP_Insert", new { Email, Mobile, OTPCode, IPAddress, CreateDate, ExpriedDate }, out UserRegisterOTP oNew); if (msg.Length > 0) { return(msg); } ID = oNew.ID; return(msg); }
static void Main(string[] args) { DBM db = new DBM(); string val = string.Empty; foreach (DataRow dr in db.getSegmentChannel().Rows) { string url = "http://*****:*****@"<View> <Query> <Where><Eq><FieldRef Name='ApprovalStatus' /><Value Type='Choice'>Pending</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy> </Query> </View>"; ListItemCollection lstitemcol = lst.GetItems(varQuery); ctx.Load(lstitemcol); ctx.ExecuteQuery(); foreach (ListItem it in lstitemcol) { val += string.Format("{0}{1}{2}','", dr["ID"].ToString(), type, it["ID"].ToString()); } } }
/// <summary> /// Trả ra đoạn HTML phân trang /// Thuộc trang Index /// </summary> public ActionResult GetPagination(int pageSize, string userName) { DBM.ExecStore("sp_User_Count", new { UserName = userName }, out int totalRow); //Đếm xem có bao nhiêu trang int totalPage = (int)Math.Ceiling((double)totalRow / pageSize); PaginationObject <UserModel> pagination = new PaginationObject <UserModel> { TotalPages = totalPage, TotalRow = totalRow, PageSize = pageSize }; return(View(pagination)); }
static void Main(string[] args) { Console.Title = "Download Blog Document"; Console.WriteLine(string.Format("Start {0}", DateTime.Now)); DBM db = new DBM(); DataTable dt = null; if (args.Length == 0) { dt = db.getListItemDocuments("", ""); } else { dt = db.getListItemDocumentsForSpecificWeb(args[0].ToString()); } foreach (DataRow dr in dt.Rows) { string tempfilepath = dr["FilePath"].ToString(); string hostName = GetHostUrl(dr["SITECOLLECTION"].ToString(), dr["SUBSITE"].ToString()); // Uri filename = new Uri(dr["SiteUrl"].ToString() +"/"+ tempfilepath); Uri filename = new Uri(hostName + tempfilepath); string server = filename.AbsoluteUri.Replace(filename.AbsolutePath, ""); string serverrelative = filename.AbsolutePath; Console.WriteLine(filename.AbsolutePath); string downloadlocationfilepath = ConfigurationManager.AppSettings["DownloadLocation"].ToString() + dr["RowID"].ToString() + "_" + serverrelative.Substring(serverrelative.LastIndexOf("/") + 1); try { Microsoft.SharePoint.Client.ClientContext clientContext = new Microsoft.SharePoint.Client.ClientContext(server); Microsoft.SharePoint.Client.FileInformation f = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, serverrelative); clientContext.ExecuteQuery(); using (var fileStream = new FileStream(downloadlocationfilepath, FileMode.Create)) f.Stream.CopyTo(fileStream); db.updateListItemDocumentDownloadStatus(dr["RowID"].ToString(), downloadlocationfilepath, dr["ListDefinationRowID"].ToString()); } catch (Exception) { db.updateListItemDocumentDownloadStatus(dr["RowID"].ToString(), null, dr["ListDefinationRowID"].ToString()); } } Console.WriteLine(string.Format("End {0}", DateTime.Now)); // Console.Read(); }
static public string GetCountByPhoneNumber(string Mobile, out int count) { count = 0; string msg = DBM.GetList("usp_UserRegisterOTP_SelectCountByMoblie", new { Mobile }, out List <UserRegisterOTP> lt); if (msg.Length > 0) { return(msg); } count = lt.Count; return(msg); }
public ActionResult AnswerVote(int answerId, int countVote) { int userId = GetUserId(); DBM.ExecStore("sp_VoteAnswer_CheckExists", new { AnswerId = answerId, UserId = userId }, out int isExists); AnswerModel answerModel = new AnswerModel { AnswerId = answerId, CountVote = countVote, IsVote = isExists == 1 ? true : false }; return(PartialView(answerModel)); }
public ActionResult ConfirmAnswer(int askId, int answerId) { int userId = GetUserId(); DBM.ExecStore("sp_Answer_CheckViewConfirmAnswer", new { AnswerId = answerId, AskId = askId, UserId = userId }, out int isConfirm); AnswerModel answerModel = new AnswerModel { AskId = askId, AnswerId = answerId, IsConfirm = isConfirm }; return(PartialView(answerModel)); }
public void Conjunction(DBM myDBM) { if (myDBM.TimerArray == null) { return; } if (TimerArray == null) { Matrix = myDBM.Matrix; TimerArray = myDBM.TimerArray; IsCanonicalForm = myDBM.IsCanonicalForm; } else if (myDBM.TimerArray != null) { Contract.Assert(TimerArray.Count == myDBM.TimerArray.Count, "//Contract-12"); /* chengbin3 */ int dimention = TimerArray.Count; for (int i = 0; i < dimention; i++) { int myith = i + 1; int ith = TimerArray.IndexOf(myDBM.TimerArray[i]) + 1; for (int j = 0; j < dimention; j++) { int myjth = j + 1; int jth = TimerArray.IndexOf(myDBM.TimerArray[j]) + 1; if (Matrix[ith][jth] > myDBM.Matrix[myith][myjth]) { Matrix[ith][jth] = myDBM.Matrix[myith][myjth]; } } } for (int i = 0; i < dimention; i++) { int myith = i + 1; int ith = TimerArray.IndexOf(myDBM.TimerArray[i]) + 1; if (Matrix[0][ith] > myDBM.Matrix[0][myith]) { Matrix[0][ith] = myDBM.Matrix[0][myith]; } if (Matrix[ith][0] > myDBM.Matrix[myith][0]) { Matrix[ith][0] = myDBM.Matrix[myith][0]; } } IsCanonicalForm = false; } }
public bool IsSubSetOf(DBM myDBM) { Contract.Requires(this.IsCanonicalForm, "IsSubSetOf Failure"); Contract.Requires(myDBM.IsCanonicalForm, "IsSubSetOf Failure"); if (myDBM.TimerArray == null) { return true; } if (this.TimerArray == null) { return false; } for (int i = 0; i < myDBM.TimerArray.Count; i++) { int index = TimerArray.IndexOf(myDBM.TimerArray[i]) + 1; if (index != 0) { if (Matrix[index][0] > myDBM.Matrix[i + 1][0] || Matrix[0][index] > myDBM.Matrix[0][i + 1]) { return false; } } else { return false; } } return true; }