Code backup
This commit is contained in:
2026-05-10 16:59:01 +02:00
commit 368d6fafea
796 changed files with 315310 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
var prod = context.ProdBom
.Join(context.ProdTable,
pb => pb.ProdId,
pt => pt.Id,
(pb, pt) => new
{
ProdBom = pb,
ProdTable = pt
})
.Where(x => x.ProdTable.ProjId == prodTable.ProjId
&& x.ProdTable.SubProjId == prodTable.SubProjId
&& x.ProdBom.ItemId == prodTable.ItemId
&& x.ProdBom.ProdId == x.ProdTable.Id)
.Select(x => x.ProdTable)
.ToList();
+28
View File
@@ -0,0 +1,28 @@
//Simple function for create log message
using System;
using System.IO;
using System.Runtime.CompilerServices;
public class Test
{
static void Log(string message,
[CallerFilePath] string file = null,
[CallerLineNumber] int line = 0)
{
Console.WriteLine("{0} ({1}): {2}", Path.GetFileName(file), line, message);
}
static void Main()
{
Log("Hello, world");
Log("This is the next line");
}
}
/*
Output:
Test.cs (16): Hello, world
Test.cs (17): This is the next line
*/
+22
View File
@@ -0,0 +1,22 @@
using System.Net.NetworkInformation;
using var ping = new Ping();
var host = "palsgnfrs01.pal.local";
while (true)
{
try
{
var reply = await ping.SendPingAsync(host, 3000);
if (reply.Status != IPStatus.Success)
Console.WriteLine($"{DateTime.Now} | Get status {Enum.GetName(reply.Status)}");
}
catch (Exception e)
{
Console.WriteLine($"{e.Message}\r\nAn error occurred while attempting to ping {host}");
}
await Task.Delay(5000);
}
@@ -0,0 +1,70 @@
namespace Console.Office365
{
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using Newtonsoft.Json.Linq;
using OfficeDevPnP.Core.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
CreateCustomPermissionLevel();
}
public static void CreateCustomPermissionLevel()
{
OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
string siteUrl = "https://*********.sharepoint.com/sites/communitysite";
string userName = "Sathish@*********.onmicrosoft.com";
string password = "************";
using (var clientContext = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
{
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.Load(web.AllProperties);
clientContext.Load(web.RoleDefinitions);
clientContext.ExecuteQueryRetry();
var roleDefinitions = web.RoleDefinitions;
// Get Owners Group and Remove the Permission Levels
var ownersGroupRoleAssignment = web.RoleAssignments.GetByPrincipal(clientContext.Web.AssociatedOwnerGroup);
ownersGroupRoleAssignment.RoleDefinitionBindings.RemoveAll();
ownersGroupRoleAssignment.Update();
clientContext.Load(ownersGroupRoleAssignment);
clientContext.ExecuteQuery();
// Get Full Control Role Definition
var customFullControlRoleDefinition = roleDefinitions.GetByName("MyPermissionLevelCreatedByCode");
clientContext.Load(customFullControlRoleDefinition);
clientContext.ExecuteQuery();
RoleDefinitionBindingCollection collRDB = new RoleDefinitionBindingCollection(clientContext);
collRDB.Add(roleDefinitions.GetByName("MyPermissionLevelCreatedByCode"));
// Bind the Newly Created Permission Level to Owners Group
web.RoleAssignments.Add(web.SiteGroups.GetById(ownersGroupRoleAssignment.PrincipalId), collRDB);
// Bind the Newly Created Permission Level to Owners Group
//ownersGroupRoleAssignment.RoleDefinitionBindings.Add(customFullControlRoleDefinition);
//ownersGroupRoleAssignment.Update();
clientContext.Load(ownersGroupRoleAssignment);
clientContext.ExecuteQuery();
}
}
}
}
+136
View File
@@ -0,0 +1,136 @@
var ctx = _sam.GetContext(new Uri("https://italsortbuttrio.sharepoint.com/sites/DevelopTest"));
//var ctx = _sam.GetContext(_so.GetPurchasingSite());
var docLibraryName = "DocList";
var name = "Test02";
//var web = ctx.Web;
//ctx.Load(web, w => w.Url);
//var list = web.Lists.GetByTitle(docLibraryName);
//ctx.Load(list, l => l.RootFolder, l => l.ContentTypes, l => l.Fields, l => l.ContentTypesEnabled);
//ctx.ExecuteQuery();
//list.ContentTypesEnabled = true;
//list.Update();
//if (!_cpt.ListContentTypeExist(ctx, docLibraryName, "Set di documenti"))
//{
// var documentCT = ctx.Site.RootWeb.AvailableContentTypes.GetById("0x0120D5");
// ctx.Load(documentCT);
// ctx.ExecuteQuery();
// var ctDocSet = new ContentTypeCreationInformation()
// {
// Name = "Set di documenti",
// ParentContentType = documentCT
// };
// list.ContentTypes.Add(ctDocSet);
// list.Update();
// ctx.ExecuteQuery();
//}
//var ctData = list.ContentTypes.Where(c => c.Name == "Set di documenti");
//var contentType = ctData.FirstOrDefault();
//ctx.Load(contentType);
//ctx.ExecuteQuery();
//DocumentSet.Create(ctx, list.RootFolder, name, contentType.Id);
//ctx.ExecuteQuery();
var oList = ctx.Web.Lists.GetByTitle(docLibraryName);
CamlQuery cQuery = new CamlQuery()
{
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{name}</Value></Eq></Where></Query></View>"
};
var collection = oList.GetItems(cQuery);
ctx.Load(collection);
ctx.ExecuteQuery();
foreach (var oListItem in collection)
{
oListItem["MultiLink"] = "<a href=\"https://www.google.com\">Link1</a>" + "<a href=\"https://www.google.com\">Link2</a>" + "<a href=\"https://www.google.com\">Link3</a>";
oListItem.Update();
}
ctx.ExecuteQuery();
//----------
//
//var j = new Dictionary<string, string[]>()
//{
// { "PAL_ML", new string[] { "Note", "MultiLine", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
// //{ "PAL_DDT", new string[] { "TaxonomyFieldType", "DDT", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
//};
//var site = ctx.Site;
//ctx.Load(site, w => w.RootWeb, w => w.RootWeb.Fields);
//ctx.ExecuteQuery();
//foreach (var f in j)
//{
// var fieldXml = $"<Field Name='{f.Key}' Type='{f.Value[0]}' Description='' DisplayName='{f.Value[1]}' StaticName='{f.Key}' Group='{f.Value[2]}' Hidden='{f.Value[3]}' Required='{f.Value[4]}' Sealed='{f.Value[5]}' ShowInDisplayForm='{f.Value[6]}' ShowInEditForm='{f.Value[7]}' ShowInNewForm='{f.Value[8]}'>{f.Value[9]}</Field>";
// site.RootWeb.Fields.AddFieldAsXml(fieldXml, false, AddFieldOptions.AddToDefaultContentType);
// ctx.Load(site.RootWeb.Fields);
//}
//ctx.ExecuteQuery();
//
//----------
//var list = ctx.Web.Lists.GetByTitle(docLibraryName);
//ctx.Load(list);
//var lFields = list.Fields;
//ctx.Load(lFields);
//ctx.ExecuteQuery();
//if (lFields == null)
//{
// foreach (var field in lFields)
// {
// if (field.InternalName.Contains("PAL_Rich"))
// {
// field.ClientSideComponentProperties.
// }
// }
//}
//----------
//
//var fields = new[] { "PAL_Rich" };
//ctx.Load(ctx.Web);
//ctx.Load(ctx.Web.Fields);
//ctx.ExecuteQuery();
//var siteColumns = ctx.Web.Fields.Where(g => g.Group == "PAL Field");
//if (siteColumns != null)
//{
// foreach (var c in siteColumns)
// {
// if (c.InternalName.Contains("PAL_RDA"))
// {
// c.TypeAsString = "TaxonomyFieldType";
// ctx.ExecuteQuery();
// }
// if (c.InternalName.Contains("PAL_DDT"))
// {
// c.TypeAsString = "TaxonomyFieldType";
// ctx.ExecuteQuery();
// }
// }
//}
//
//---------
+29
View File
@@ -0,0 +1,29 @@
string[] projs = new string[] { "CT22-0029", "CT22-0031" };
foreach (var projName in projs)
{
var subProjSite = siteOptions.GetSubProjSite(projName);
var ctx = authenticationManager.GetContext(subProjSite);
var docLibName = $"Commerciale {projName}";
var web = ctx.Web;
var list = web.Lists.GetByTitle(docLibName);
ctx.Load(list);
list.BreakRoleInheritance(false, true);
ctx.ExecuteQuery();
var adGroup = web.EnsureUser("accounting@italsortbuttrio.onmicrosoft.com");
ctx.Load(adGroup);
var roleD = web.RoleDefinitions.GetByName("Contribute");
var roleDb = new RoleDefinitionBindingCollection(ctx) { roleD };
list.RoleAssignments.Add(adGroup, roleDb);
list.Update();
ctx.ExecuteQuery();
Console.WriteLine($"Done for {projName}");
}
+19
View File
@@ -0,0 +1,19 @@
void FieldDelete(clientContext ctx, string[] fieldNames)
{
foreach (var field in fieldNames)
{
var web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
var field = web.Fields.GetByInternalNameOrTitle(field);
if (field != null)
{
field.SetAllowDeletion(true);
field.DeleteObject();
web.Update();
ctx.ExecuteQuery();
}
}
}
+7
View File
@@ -0,0 +1,7 @@
// log first row of datagrid selected
function selection_change(selectedRecord) {
var data = selectedRecord.selectedRowsData[0];
if (data != undefined){
console.log(data);
}
}
+17
View File
@@ -0,0 +1,17 @@
// Override Method - modified - Grid Item
// Permette di avere un campo selezionato allinterno di più righe e aggiornare la griglia visualizzata quando viene cliccato il campo desiderato.
public boolean modified()
{
boolean ret;
TestCheck tchk;
ret = super();
if(TestCheck_NoYesBlank.value() == NoYes::Yes)
{
update_recordset tchk
setting NoYesBlank = NoYes::No where tchk.NoYesBlank == noyes::Yes;
TestCheck_ds.research();
}
return ret;
}
+20
View File
@@ -0,0 +1,20 @@
Aggiungere come metodo il display del campo
public display ReqGroupId reqGroupId()
{
return InventTable::find(this.ItemId).ReqGroupId;
}
PALEBI_ServiceOperation so;
ttsBegin;
while select forupdate so
where so.PALEBI_ServiceOperationId == 'SO26-00169'
{
so.ApprovedBy = 'asa';
so.update();
}
ttsCommit;