public void Update(string tittle, string desc, string note, string url, bool?active, DateTime?created, long id) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); WEBSERVICE webservice = Queryable.Single <WEBSERVICE>((IQueryable <WEBSERVICE>)classes1DataContext.WEBSERVICEs, (Expression <Func <WEBSERVICE, bool> >)(p => p.ID == id)); if (tittle != null) { webservice.Tittle = Convert.ToString(tittle); } if (desc != null) { webservice.Description = Convert.ToString(desc); } if (note != null) { webservice.Note = Convert.ToString(note); } if (url != null) { webservice.URL = Convert.ToString(url); } if (active.HasValue) { webservice.Active = Convert.ToBoolean((object)active); } if (created.HasValue) { webservice.CreatedOn = Convert.ToDateTime((object)created); } classes1DataContext.SubmitChanges(); }
public List <HelpClassUsers> GetUsersByWSNew(WEBSERVICE ws) { IQueryable <USER> queryable = Queryable.Distinct <USER>(Queryable.Select <PERMISSION, USER>(Queryable.Where <PERMISSION>((IQueryable <PERMISSION>) new DataClasses1DataContext().PERMISSIONs, (Expression <Func <PERMISSION, bool> >)(p => p.Active == true && p.ID_WS == ws.ID && p.USER.Active == true)), (Expression <Func <PERMISSION, USER> >)(p => p.USER))); List <HelpClassUsers> list = new List <HelpClassUsers>(); foreach (USER user in (IEnumerable <USER>)queryable) { list.Add(new HelpClassUsers() { ID = user.ID, Name = user.Name, Surname = user.Surname, ID_Cert = Convert.ToInt64((object)user.ID_CERT), NameSurname = user.Name + " " + user.Surname, Email = user.email, Active = user.Active, CreatedOn = user.CreateOn, user = user.username, pass = user.password, Type = user.Type, UserObj = user, ip = user.IpAdress }); } return(list); }
public List <WEBSERVICE> GetServicesByIstitution(INSTITUTION inst) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); List <WEBSERVICE> allActiveDeleted = this.GetAllActiveDeleted(true); List <WEBSERVICE> list = new List <WEBSERVICE>(); using (List <WEBSERVICE> .Enumerator enumerator = allActiveDeleted.GetEnumerator()) { while (enumerator.MoveNext()) { WEBSERVICE c = enumerator.Current; IQueryable <PERMISSION> source = Queryable.Where <PERMISSION>((IQueryable <PERMISSION>)classes1DataContext.PERMISSIONs, (Expression <Func <PERMISSION, bool> >)(p => p.Active == true && p.INSTITUTION.ID == inst.ID && p.ID_WS == c.ID && p.WEBSERVICE.Active == true)); try { if (Queryable.Count <PERMISSION>(source) != 0) { list.Add(c); } } catch { } } } return(list); }
protected void Gridview2_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } ImageButton imageButton = (ImageButton)e.Row.FindControl("Insert"); WEBSERVICE c = (WEBSERVICE)e.Row.DataItem; if (c != null) { imageButton.Attributes.Add("1", c.ID.ToString()); List <WEBSERVICE> list = (List <WEBSERVICE>) this.Application["ListWSUser"]; try { Enumerable.First <WEBSERVICE>((IEnumerable <WEBSERVICE>)list, (Func <WEBSERVICE, bool>)(p => p.ID == c.ID)); imageButton.ImageUrl = "../rerources/images/add.png"; imageButton.CommandName = "DeleteWS"; } catch { imageButton.CommandName = "InsertWS"; } } }
public void Update(INSTITUTION inst, USER user, WEBSERVICE ws, int?use, bool?active, DateTime?created, long id) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); PERMISSION permission = Queryable.Single <PERMISSION>((IQueryable <PERMISSION>)classes1DataContext.PERMISSIONs, (Expression <Func <PERMISSION, bool> >)(p => p.ID == id)); if (inst != null) { permission.INSTITUTION = inst; } if (user != null) { permission.USER = user; } if (ws != null) { permission.WEBSERVICE = ws; } if (use.HasValue) { permission.Usage = Convert.ToInt32((object)use); } if (active.HasValue) { permission.Active = Convert.ToBoolean((object)active); } if (created.HasValue) { permission.CreatedOn = Convert.ToDateTime((object)created); } classes1DataContext.SubmitChanges(); }
public void Update(string title, string desc, int?maxlen, int?type, WEBSERVICE ws, bool?active, long id) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); PARAM obj = Queryable.Single <PARAM>((IQueryable <PARAM>)classes1DataContext.PARAMs, (Expression <Func <PARAM, bool> >)(p => p.ID == id)); if (title != null) { obj.Tittle = Convert.ToString(title); } if (desc != null) { obj.Description = Convert.ToString(desc); } if (maxlen.HasValue) { obj.MaxLength = Convert.ToInt32((object)maxlen); } if (type.HasValue) { obj.Type = Convert.ToInt32((object)type); } if (ws != null) { obj.WEBSERVICE = ws; } if (active.HasValue) { obj.Acitve = Convert.ToBoolean((object)active); } classes1DataContext.SubmitChanges(); }
protected void Gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e) { WEBSERVICE ws = (WEBSERVICE)this.Application["WS"]; string TittleText = ((TextBox)this.Gridview1.Rows[e.RowIndex].FindControl("EditTittle")).Text; string DescText = ((TextBox)this.Gridview1.Rows[e.RowIndex].FindControl("EditDescription")).Text; if (ws == null) { return; } List <PARAM> paramsForWebservice = new ParamsDAL().GetParamsForWebservice(ws); try { PARAM obj = Enumerable.Single <PARAM>((IEnumerable <PARAM>)paramsForWebservice, (Func <PARAM, bool>)(p => p.Description == DescText && p.Tittle == TittleText)); new ParamsDAL().Delete(obj.ID); string old = ""; string newone = ""; new LOGDAL().Insert(Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PARAMS")).Key, (USER)this.Session["user"], obj.ID.ToString(), 3, DateTime.Now, old, newone); this.Gridview1.DataSource = (object)new ParamsDAL().GetParamsForWebservice(ws); this.Gridview1.DataBind(); } catch { this.Gridview1.DataSource = (object)new ParamsDAL().GetParamsForWebservice(ws); this.Gridview1.DataBind(); } }
public HelpClassWebServices GetByIDPermisions(long id) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); try { WEBSERVICE ws = Queryable.Single <WEBSERVICE>((IQueryable <WEBSERVICE>)classes1DataContext.WEBSERVICEs, (Expression <Func <WEBSERVICE, bool> >)(p => p.ID == id)); HelpClassWebServices classWebServices = new HelpClassWebServices(); List <PERMISSION> permisionsByWs = new PermissionsDAL().GetPermisionsByWS(ws); classWebServices.ID = ws.ID; classWebServices.Tittle = ws.Tittle; classWebServices.Description = ws.Description; classWebServices.Note = ws.Note; classWebServices.URL = ws.URL; classWebServices.Active = ws.Active; classWebServices.CreatedOn = ws.CreatedOn; classWebServices.WSObj = ws; classWebServices.IDInstitution = 0L; classWebServices.InstitutionName = "x"; if (permisionsByWs.Count != 0) { classWebServices.IDInstitution = permisionsByWs[0].INSTITUTION.ID; classWebServices.InstitutionName = permisionsByWs[0].INSTITUTION.Tittle; } classWebServices.PermissionList = permisionsByWs; return(classWebServices); } catch { return((HelpClassWebServices)null); } }
protected void LinkButtonPromeni_Click(object sender, EventArgs e) { bool flag = false; for (int index = 0; index < this.CheckBoxListUser.Items.Count; ++index) { if (this.CheckBoxListUser.Items[index].Selected) { flag = true; break; } } if (!flag) { return; } List <WEBSERVICE> list = (List <WEBSERVICE>) this.Session["ListWSUser"]; HelpClassUsers helpClassUsers = (HelpClassUsers)this.Application["UserPermission"]; INSTITUTION byId1 = new InstitutionsDAL().GetByID(helpClassUsers.IDInstitution); USER byId2 = new UsersDAL().GetByID(helpClassUsers.ID); KeyValuePair <int, string> keyValuePair; for (int i = 0; i < this.CheckBoxListUser.Items.Count; ++i) { if (this.CheckBoxListUser.Items[i].Selected) { try { Enumerable.Single <WEBSERVICE>((IEnumerable <WEBSERVICE>)list, (Func <WEBSERVICE, bool>)(p => p.ID == Convert.ToInt64(this.CheckBoxListUser.Items[i].Value))); } catch { WEBSERVICE byId3 = new WebservicesDAL().GetByID(Convert.ToInt64(this.CheckBoxListUser.Items[i].Value)); long num = new PermissionsDAL().Insert(byId1, byId2, byId3, 2, true, DateTime.Now); string old = ""; string newone = ""; keyValuePair = Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PERMISSIONS")); new LOGDAL().Insert(keyValuePair.Key, (USER)this.Session["user"], num.ToString(), 1, DateTime.Now, old, newone); } } else { try { WEBSERVICE ws = Enumerable.Single <WEBSERVICE>((IEnumerable <WEBSERVICE>)list, (Func <WEBSERVICE, bool>)(p => p.ID == Convert.ToInt64(this.CheckBoxListUser.Items[i].Value))); PERMISSION permission = Enumerable.Single <PERMISSION>((IEnumerable <PERMISSION>)helpClassUsers.PermissionList, (Func <PERMISSION, bool>)(p => p.ID_WS == ws.ID && p.Usage == 2)); new PermissionsDAL().Update((INSTITUTION)null, (USER)null, (WEBSERVICE)null, new int?(), new bool?(false), new DateTime?(), permission.ID); string old = ""; string newone = ""; keyValuePair = Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PERMISSIONS")); new LOGDAL().Insert(keyValuePair.Key, (USER)this.Session["user"], permission.ID.ToString(), 2, DateTime.Now, old, newone); } catch { } } } }
public List <PARAM> GetParamsForWebservice(WEBSERVICE ws) { IQueryable <PARAM> queryable = Queryable.Where <PARAM>((IQueryable <PARAM>) new DataClasses1DataContext().PARAMs, (Expression <Func <PARAM, bool> >)(p => p.Acitve == true && p.WEBSERVICE.ID == ws.ID)); List <PARAM> list = new List <PARAM>(); foreach (PARAM obj in (IEnumerable <PARAM>)queryable) { list.Add(obj); } return(list); }
public List <PERMISSION> GetPermisionsByWS(WEBSERVICE ws) { IQueryable <PERMISSION> queryable = Queryable.Where <PERMISSION>((IQueryable <PERMISSION>) new DataClasses1DataContext().PERMISSIONs, (Expression <Func <PERMISSION, bool> >)(p => p.Active == true && p.WEBSERVICE.ID == ws.ID && p.Usage == 1)); List <PERMISSION> list = new List <PERMISSION>(); foreach (PERMISSION permission in (IEnumerable <PERMISSION>)queryable) { list.Add(permission); } return(list); }
protected void Gridview2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteWS") { long num = Convert.ToInt64(((WebControl)e.CommandSource).Attributes["1"]); List <WEBSERVICE> list = (List <WEBSERVICE>) this.Application["ListWSUser"]; using (List <WEBSERVICE> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { WEBSERVICE c = enumerator.Current; if (c.ID == num) { HelpClassUsers helpClassUsers = (HelpClassUsers)this.Application["UserPermission"]; if (helpClassUsers.PermissionList.Count > 1) { list.Remove(c); PERMISSION permission = Enumerable.First <PERMISSION>((IEnumerable <PERMISSION>)helpClassUsers.PermissionList, (Func <PERMISSION, bool>)(p => p.ID_WS == c.ID && p.Usage == 2 && p.Active)); new PermissionsDAL().Update((INSTITUTION)null, (USER)null, (WEBSERVICE)null, new int?(), new bool?(false), new DateTime?(), permission.ID); string old = ""; string newone = ""; new LOGDAL().Insert(Enumerable.First <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PERMISSIONS")).Key, (USER)this.Session["user"], permission.ID.ToString(), 2, DateTime.Now, old, newone); this.Application["ListUsersPermissionsPerm"] = (object)new UsersDAL().GetUsersInstitutionsPermissions(2, true); this.Application["UserPermission"] = (object)Enumerable.First <HelpClassUsers>((IEnumerable <HelpClassUsers>) this.Application["ListUsersPermissionsPerm"], (Func <HelpClassUsers, bool>)(p => p.ID == (Guid)this.Application["SelectedUser"])); break; } break; } } } this.Application["ListWSUser"] = (object)list; this.Gridview2.DataBind(); } else { if (!(e.CommandName == "InsertWS")) { return; } WEBSERVICE byId = new WebservicesDAL().GetByID(Convert.ToInt64(((WebControl)e.CommandSource).Attributes["1"])); List <WEBSERVICE> list = (List <WEBSERVICE>) this.Application["ListWSUser"]; list.Add(byId); this.Application["ListWSUser"] = (object)list; this.Gridview2.DataBind(); HelpClassUsers helpClassUsers = (HelpClassUsers)this.Application["UserPermission"]; long num = new PermissionsDAL().Insert(new InstitutionsDAL().GetByID(helpClassUsers.IDInstitution), new UsersDAL().GetByID(helpClassUsers.ID), byId, 2, true, DateTime.Now); string old = ""; string newone = ""; new LOGDAL().Insert(Enumerable.First <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PERMISSIONS")).Key, (USER)this.Session["user"], num.ToString(), 1, DateTime.Now, old, newone); this.Application["ListUsersPermissionsPerm"] = (object)new UsersDAL().GetUsersInstitutionsPermissions(2, true); this.Application["UserPermission"] = (object)Enumerable.First <HelpClassUsers>((IEnumerable <HelpClassUsers>) this.Application["ListUsersPermissionsPerm"], (Func <HelpClassUsers, bool>)(p => p.ID == (Guid)this.Application["SelectedUser"])); } }
public DOCUMENTSTRUCTURE GetByWebService(WEBSERVICE ws) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); try { return(Queryable.Single <DOCUMENTSTRUCTURE>((IQueryable <DOCUMENTSTRUCTURE>)classes1DataContext.DOCUMENTSTRUCTUREs, (Expression <Func <DOCUMENTSTRUCTURE, bool> >)(p => p.ID_WS == ws.ID))); } catch { return((DOCUMENTSTRUCTURE)null); } }
public long Insert(string title, string desc, int maxlen, int type, WEBSERVICE ws, bool active) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); PARAM entity = new PARAM(); entity.Tittle = title; entity.Description = desc; entity.MaxLength = maxlen; entity.Type = type; entity.ID_WS = ws.ID; entity.Acitve = active; classes1DataContext.PARAMs.InsertOnSubmit(entity); classes1DataContext.SubmitChanges(); return(entity.ID); }
public long Insert(string tittle, string desc, string note, string url, bool active, DateTime created) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); WEBSERVICE entity = new WEBSERVICE(); entity.Tittle = tittle; entity.Description = desc; entity.Note = note; entity.URL = url; entity.Active = active; entity.CreatedOn = created; classes1DataContext.WEBSERVICEs.InsertOnSubmit(entity); classes1DataContext.SubmitChanges(); return(entity.ID); }
public long Insert(INSTITUTION inst, USER user, WEBSERVICE ws, int use, bool active, DateTime created) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); PERMISSION entity = new PERMISSION(); entity.ID_INST = inst.ID; entity.ID_USER = user.ID; entity.ID_WS = ws.ID; entity.Usage = use; entity.Active = active; entity.CreatedOn = created; classes1DataContext.PERMISSIONs.InsertOnSubmit(entity); classes1DataContext.SubmitChanges(); return(entity.ID); }
protected void DropDonwListInstitution_SelectedIndexChanged(object sender, EventArgs e) { WEBSERVICE webservice = new WEBSERVICE(); webservice.ID = 0L; webservice.Tittle = "-- Сервиси --"; List <WEBSERVICE> list = new List <WEBSERVICE>(); List <WEBSERVICE> institutionPermission = new WebservicesDAL().GetAllByInstitutionPermission(Convert.ToInt64(this.DropDonwListInstitution.SelectedValue)); list.Add(webservice); list.AddRange((IEnumerable <WEBSERVICE>)institutionPermission); this.DropDownListServis.DataTextField = "Tittle"; this.DropDownListServis.DataValueField = "ID"; this.DropDownListServis.DataSource = (object)list; this.DropDownListServis.DataBind(); }
public List <WEBSERVICE> GetAllOtherWebServices(INSTITUTION inst) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); List <WEBSERVICE> allActiveDeleted = this.GetAllActiveDeleted(true); List <WEBSERVICE> list = new List <WEBSERVICE>(); using (List <WEBSERVICE> .Enumerator enumerator = allActiveDeleted.GetEnumerator()) { while (enumerator.MoveNext()) { WEBSERVICE c = enumerator.Current; if (Queryable.Count <PERMISSION>(Queryable.Where <PERMISSION>((IQueryable <PERMISSION>)classes1DataContext.PERMISSIONs, (Expression <Func <PERMISSION, bool> >)(p => p.Active == true && p.INSTITUTION.ID == inst.ID && p.Usage == 1 && p.ID_WS == c.ID))) == 0) { list.Add(c); } } } return(list); }
protected void Gridview1_SelectedIndexChanged(object sender, EventArgs e) { TextBox textBox1 = (TextBox)this.Gridview1.SelectedRow.FindControl("EditTittle"); TextBox textBox2 = (TextBox)this.Gridview1.SelectedRow.FindControl("EditDescription"); long id = Convert.ToInt64(this.Gridview1.SelectedDataKey.Value); WEBSERVICE ws = (WEBSERVICE)this.Application["WS"]; if (ws == null) { return; } PARAM byId = new ParamsDAL().GetByID(id); new ParamsDAL().Update(textBox1.Text, textBox2.Text, new int?(), new int?(), (WEBSERVICE)null, new bool?(), id); string old = byId.Tittle + ";" + byId.Description; string newone = textBox1.Text + ";" + textBox2.Text; new LOGDAL().Insert(Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PARAMS")).Key, (USER)this.Session["user"], id.ToString(), 2, DateTime.Now, old, newone); this.Gridview1.DataSource = (object)new ParamsDAL().GetParamsForWebservice(ws); this.Gridview1.DataBind(); }
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "NoDataInsert") { TextBox textBox1 = (TextBox)this.Gridview1.Controls[0].Controls[0].FindControl("NoDataTittle"); TextBox textBox2 = (TextBox)this.Gridview1.Controls[0].Controls[0].FindControl("NoDataDescription"); WEBSERVICE ws = (WEBSERVICE)this.Application["WS"]; if (ws == null) { return; } long num = new ParamsDAL().Insert(textBox1.Text, textBox2.Text, 50, 1, ws, true); string old = textBox1.Text + ";" + textBox2.Text + ";50;1;" + true.ToString(); string newone = ""; new LOGDAL().Insert(Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PARAMS")).Key, (USER)this.Session["user"], num.ToString(), 1, DateTime.Now, old, newone); this.Gridview1.DataSource = (object)new ParamsDAL().GetParamsForWebservice(ws); this.Gridview1.DataBind(); } else { if (!(e.CommandName == "InsertNew")) { return; } TextBox textBox1 = (TextBox)this.Gridview1.FooterRow.FindControl("InsertTittle"); TextBox textBox2 = (TextBox)this.Gridview1.FooterRow.FindControl("InsertDescription"); WEBSERVICE ws = (WEBSERVICE)this.Application["WS"]; if (ws != null) { long num = new ParamsDAL().Insert(textBox1.Text, textBox2.Text, 50, 1, ws, true); string old = textBox1.Text + ";" + textBox2.Text + ";50;1;" + true.ToString(); string newone = ""; new LOGDAL().Insert(Enumerable.Single <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "PARAMS")).Key, (USER)this.Session["user"], num.ToString(), 1, DateTime.Now, old, newone); this.Gridview1.DataSource = (object)new ParamsDAL().GetParamsForWebservice(ws); this.Gridview1.DataBind(); } } }