Skip to content

Commit a7add4e

Browse files
committed
Adicionar arquivos de projeto.
1 parent 30dcf7f commit a7add4e

17 files changed

Lines changed: 1305 additions & 0 deletions

‎SPOtoSQL-Snapshots/.DS_Store‎

6 KB
Binary file not shown.
8 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("ConsoleApp1")]
5+
[assembly: AssemblyDescription("")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("")]
8+
[assembly: AssemblyProduct("ConsoleApp1")]
9+
[assembly: AssemblyCopyright("Copyright © 2017")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: ComVisible(false)]
12+
[assembly: Guid("20b7ee6b-7aab-4e27-bcf3-8245b81b3ca6")]
13+
[assembly: AssemblyFileVersion("1.0.0.0")]
14+
[assembly: AssemblyVersion("1.0.0.0")]
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!--Project was exported from assembly: C:\Users\KEVIN\Desktop\Visual Studio\SPtoSP\ConsoleApp1.exe-->
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AssemblyName>ConsoleApp1</AssemblyName>
10+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
11+
<ApplicationVersion>1.0.0.0</ApplicationVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<RootNamespace>Bring</RootNamespace>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="Microsoft.Office.Client.Policy, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
36+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.Office.Client.Policy.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Microsoft.Office.Client.TranslationServices, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
39+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.Office.Client.TranslationServices.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Microsoft.Office.SharePoint.Tools, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
42+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.Office.SharePoint.Tools.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Microsoft.Online.SharePoint.Client.Tenant, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
45+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.Online.SharePoint.Client.Tenant.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Microsoft.ProjectServer.Client, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
48+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.ProjectServer.Client.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Microsoft.SharePoint.Client, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
51+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.dll</HintPath>
52+
</Reference>
53+
<Reference Include="Microsoft.SharePoint.Client.DocumentManagement, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
54+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.DocumentManagement.dll</HintPath>
55+
</Reference>
56+
<Reference Include="Microsoft.SharePoint.Client.Publishing, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
57+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Publishing.dll</HintPath>
58+
</Reference>
59+
<Reference Include="Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
60+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Runtime.dll</HintPath>
61+
</Reference>
62+
<Reference Include="Microsoft.SharePoint.Client.Runtime.Windows, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
63+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Runtime.Windows.dll</HintPath>
64+
</Reference>
65+
<Reference Include="Microsoft.SharePoint.Client.Search, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
66+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Search.dll</HintPath>
67+
</Reference>
68+
<Reference Include="Microsoft.SharePoint.Client.Search.Applications, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
69+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Search.Applications.dll</HintPath>
70+
</Reference>
71+
<Reference Include="Microsoft.SharePoint.Client.Taxonomy, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
72+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.Taxonomy.dll</HintPath>
73+
</Reference>
74+
<Reference Include="Microsoft.SharePoint.Client.UserProfiles, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
75+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.UserProfiles.dll</HintPath>
76+
</Reference>
77+
<Reference Include="Microsoft.SharePoint.Client.WorkflowServices, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
78+
<HintPath>packages\Microsoft.SharePointOnline.CSOM.16.1.19814.12000\lib\net45\Microsoft.SharePoint.Client.WorkflowServices.dll</HintPath>
79+
</Reference>
80+
<Reference Include="System" />
81+
<Reference Include="System.Configuration" />
82+
<Reference Include="System.Core" />
83+
<Reference Include="System.Data" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<Compile Include="SPODataQuality\RefreshSPOLists.cs" />
87+
<Compile Include="Sqlserver\RefreshSQLLists.cs" />
88+
<Compile Include="Sqlserver\SQLInteraction.cs" />
89+
<Compile Include="Sharepoint\ActivitiesDQ.cs" />
90+
<Compile Include="Sharepoint\GetallLists.cs" />
91+
<Compile Include="Sharepoint\InvoiceRequestDQ.cs" />
92+
<Compile Include="Sharepoint\Constants.cs" />
93+
<Compile Include="Sharepoint\Context.cs" />
94+
<Compile Include="Sharepoint\SPOList.cs" />
95+
<Compile Include="Sharepoint\SPOUser.cs" />
96+
<Compile Include="Sharepoint\TimesheetDQ.cs" />
97+
<Compile Include="AssemblyInfo.cs" />
98+
</ItemGroup>
99+
<ItemGroup>
100+
<None Include="packages.config" />
101+
</ItemGroup>
102+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103+
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1.csproj", "{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{2F127D05-3822-4C73-840C-0BF0D7EBBF8C}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
using Bring.Sharepoint;
2+
using Bring.Sqlserver;
3+
using Microsoft.SharePoint.Client;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq.Expressions;
7+
using System.Xml;
8+
9+
namespace Bring.SPODataQuality
10+
{
11+
internal class RefreshSPOLists
12+
{
13+
private static void Main(string[] args)
14+
{
15+
try
16+
{
17+
Console.WriteLine("DEBUG: Iniciando Main");
18+
Console.WriteLine("CURRENT TIME: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
19+
20+
SPOUser spoUser = new SPOUser("Guilherme.sales@bringglobal.com", "UtKid_3AV^r]H+");
21+
Console.WriteLine("DEBUG: SPOUser criado");
22+
23+
var list1 = new SPOList();
24+
list1.SPOUser = spoUser;
25+
Console.WriteLine("DEBUG: Primeiro SPOList configurado"); // Debug
26+
27+
var list2 = new SPOList();
28+
list2.SPOUser = spoUser;
29+
Console.WriteLine("DEBUG: Segundo SPOList configurado"); //Debug
30+
31+
if ((uint)args.Length > 0U)
32+
{
33+
string lower = args[0].ToLower();
34+
Console.WriteLine("DEBUG: Argumento recebido - " + lower); //Debug
35+
36+
if (!(lower == "daily"))
37+
{
38+
if (lower == "monthly")
39+
{
40+
Console.WriteLine("DEBUG: Executando monthly");
41+
RefreshSQLLists.SPOtoSQLUpdate(false);
42+
}
43+
else
44+
{
45+
Console.WriteLine("Unrecognized argument, please use daily or monthly as the argument");
46+
}
47+
}
48+
else
49+
{
50+
Console.WriteLine("DEBUG: Executando daily"); //Debug
51+
RefreshSQLLists.SPOtoSQLUpdate(true);
52+
}
53+
}
54+
55+
Console.WriteLine("End of requests.");
56+
Console.WriteLine();
57+
}
58+
catch (Exception ex)
59+
{
60+
Console.WriteLine("An error occurred: " + ex.Message);
61+
}
62+
}
63+
64+
public static void GetAllLists()
65+
{
66+
Console.WriteLine("DEBUG: Entrando em GetAllLists"); // Debug
67+
SPOUser spoUser = new SPOUser("Guilherme.sales@bringglobal.com", "UtKid_3AV^r]H+");
68+
Context context = new Context()
69+
{
70+
Site = "seed",
71+
SPOUser = spoUser
72+
};
73+
foreach (List allList in (ClientObjectCollection<List>)context.GetAllLists())
74+
{
75+
Console.WriteLine("DEBUG: Carregando lista - " + allList.Title); // Debug
76+
context.Ctx.Load<List>(allList, new Expression<Func<List, object>>[1]
77+
{
78+
(Expression<Func<List, object>>) (l => (object) l.IsSystemList)
79+
});
80+
context.Ctx.ExecuteQuery();
81+
Console.WriteLine("List Name: " + allList.Title + "; is: " + allList.IsSystemList.ToString());
82+
}
83+
}
84+
85+
private static void SPODebug(string listName, string ctxURL, SPOUser user)
86+
{
87+
Console.WriteLine("DEBUG: Entrando em SPODebug"); // Debug
88+
SPOList spoList = new SPOList
89+
{
90+
Name = listName,
91+
Site = ctxURL,
92+
SPOUser = user,
93+
CAMLQuery = "<View><RowLimit>1</RowLimit></View>"
94+
};
95+
96+
Console.WriteLine("DEBUG: Executando Build"); // Debug
97+
spoList.Build();
98+
99+
Console.WriteLine("DEBUG: Executando PropsToString");
100+
spoList.PropsToString(spoList.ItemCollection[0]);
101+
}
102+
103+
private static void RefreshListsSPO(SPOList sourceList, SPOList destList)
104+
{
105+
try
106+
{
107+
Console.WriteLine("DEBUG: Iniciando RefreshListsSPO"); // Debug
108+
109+
sourceList.Build();
110+
Console.WriteLine("DEBUG: sourceList.Build concluído"); // Debug
111+
112+
destList.Build();
113+
Console.WriteLine("DEBUG: destList.Build concluído");
114+
115+
int num1 = 0;
116+
int num2 = 0;
117+
118+
string[,] actualFields = GetActualFields(sourceList, destList);
119+
Console.WriteLine("DEBUG: Campos obtidos"); // Debug
120+
121+
if ((uint)sourceList.ItemCollection.Count > 0U)
122+
num1 = (int)sourceList.ItemCollection[sourceList.ItemCollection.Count - 1]["ID"];
123+
if ((uint)destList.ItemCollection.Count > 0U)
124+
num2 = (int)destList.ItemCollection[destList.ItemCollection.Count - 1]["ID"];
125+
126+
if (num2 < num1)
127+
{
128+
Console.WriteLine("DEBUG: Adicionando novos itens"); // Debug
129+
do
130+
{
131+
destList.AddItem();
132+
++num2;
133+
}
134+
while (num2 < num1);
135+
136+
Console.WriteLine("Adding new items...");
137+
destList.Update();
138+
Console.WriteLine("Done adding items.");
139+
}
140+
141+
for (int index1 = 0; index1 < sourceList.ItemCollection.Count; ++index1)
142+
{
143+
int id = (int)sourceList.ItemCollection[index1]["ID"];
144+
for (int index2 = 0; index2 < actualFields.Length / 2; ++index2)
145+
destList.ItemCollection.GetById(id)[actualFields[index2, 0]] = sourceList.ItemCollection[index1][actualFields[index2, 1]];
146+
destList.ItemCollection.GetById(id).Update();
147+
}
148+
149+
destList.Ctx.ExecuteQuery();
150+
Console.WriteLine(sourceList.Site + " " + sourceList.Name + " -> " + destList.Site + " " + destList.Name + ": Done!");
151+
}
152+
catch (Exception ex)
153+
{
154+
Console.WriteLine("ERROR in RefreshListsSPO: " + ex.Message);
155+
}
156+
}
157+
158+
private static string[,] GetActualFields(SPOList listone, SPOList listtwo)
159+
{
160+
Console.WriteLine("DEBUG: Entrando em GetActualFields"); // Debug
161+
162+
List<Field> fields1 = GetFields(listone);
163+
List<Field> fields2 = GetFields(listtwo);
164+
165+
string[,] strArray = new string[fields1.Count, 2];
166+
int index1 = 0;
167+
int index2 = 0;
168+
169+
foreach (Field field1 in fields1)
170+
{
171+
Field field2;
172+
do
173+
{
174+
field2 = fields2[index2];
175+
if (field1.Title == field2.Title)
176+
{
177+
strArray[index1, 0] = field2.InternalName;
178+
strArray[index1, 1] = field1.InternalName;
179+
Console.WriteLine($"DEBUG: Match found - {field1.Title}"); // Debug
180+
}
181+
++index2;
182+
}
183+
while (field1.Title != field2.Title && index2 < fields2.Count);
184+
185+
++index1;
186+
index2 = 0;
187+
}
188+
189+
return strArray;
190+
}
191+
192+
private static List<Field> GetFields(SPOList list)
193+
{
194+
Console.WriteLine("DEBUG: Entrando em GetFields"); // Debug
195+
196+
List<Field> fieldList = new List<Field>();
197+
foreach (Field field in (ClientObjectCollection<Field>)list.Fields)
198+
{
199+
if (!field.FromBaseType || field.InternalName == "Title")
200+
{
201+
fieldList.Add(field);
202+
Console.WriteLine($"DEBUG: Campo adicionado - {field.Title}"); // Debug
203+
}
204+
}
205+
206+
return fieldList;
207+
}
208+
}
209+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Decompiled with JetBrains decompiler
2+
// Type: Bring.Sharepoint.ActivitiesDQ
3+
// Assembly: ConsoleApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
4+
// MVID: 2529ACA9-9F81-4C49-8E47-E8B02D261367
5+
// Assembly location: C:\Users\KEVIN\Desktop\Visual Studio\SPtoSP\ConsoleApp1.exe
6+
7+
using Microsoft.SharePoint.Client;
8+
9+
namespace Bring.Sharepoint
10+
{
11+
internal class ActivitiesDQ
12+
{
13+
public SPOUser Me { get; set; }
14+
15+
public bool UpdateIDs()
16+
{
17+
string str = "<View><Query><Where><IsNull><FieldRef Name ='_OpportunityID' /></IsNull></Where></Query></View>";
18+
SPOList spoList1 = new SPOList();
19+
spoList1.Name = "activities";
20+
spoList1.Site = "wolf";
21+
spoList1.SPOUser = this.Me;
22+
spoList1.CAMLQuery = str;
23+
SPOList spoList2 = spoList1;
24+
spoList2.Build();
25+
foreach (ListItem listItem in (ClientObjectCollection<ListItem>) spoList2.ItemCollection)
26+
{
27+
listItem["_OpportunityID"] = listItem["OpportunityID"];
28+
listItem.Update();
29+
}
30+
spoList2.Ctx.ExecuteQuery();
31+
return true;
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)