-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eabaeb
commit 13df297
Showing
298 changed files
with
40,664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{D8ABCB97-7536-4A79-863D-0AA118ADB77A}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Anketbaz.Data</RootNamespace> | ||
<AssemblyName>Anketbaz.Data</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="EntityFramework"> | ||
<HintPath>..\RestaurantApp.Library\Libraries\EntityFramework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ICSharpCode.SharpZipLib"> | ||
<HintPath>..\Anketbaz.Library\Libraries\ICSharpCode.SharpZipLib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\Anketbaz.Library\Libraries\MySql.Data.dll</HintPath> | ||
</Reference> | ||
<Reference Include="MySql.Data.Entity, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\Anketbaz.Library\Libraries\MySql.Data.Entity.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\Anketbaz.Library\Libraries\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NPOI"> | ||
<HintPath>..\Anketbaz.Library\Libraries\NPOI.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NPOI.OOXML"> | ||
<HintPath>..\Anketbaz.Library\Libraries\NPOI.OOXML.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NPOI.OpenXml4Net"> | ||
<HintPath>..\Anketbaz.Library\Libraries\NPOI.OpenXml4Net.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NPOI.OpenXmlFormats"> | ||
<HintPath>..\Anketbaz.Library\Libraries\NPOI.OpenXmlFormats.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="EntityConnectionService.cs" /> | ||
<Compile Include="Logical\DatabaseService.cs" /> | ||
<Compile Include="Logical\Exporter.cs" /> | ||
<Compile Include="Logical\PollBusiness.cs" /> | ||
<Compile Include="Logical\TestService.cs" /> | ||
<Compile Include="Models\FullPollModel.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Services\PollService.cs" /> | ||
<Compile Include="Services\StaffService.cs" /> | ||
<Compile Include="Services\UserService.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Anketbaz.Database\Anketbaz.Database.csproj"> | ||
<Project>{d61e8e31-9b84-4340-9e08-c5516c38ef4e}</Project> | ||
<Name>Anketbaz.Database</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Anketbaz.Database.Repositories; | ||
|
||
namespace Anketbaz.Data | ||
{ | ||
public static class EntityConnectionService | ||
{ | ||
|
||
public static readonly ICompanyRepository Company = new CompanyRepository(); | ||
public static readonly IAnswerRepository Answer = new AnswerRepository(); | ||
public static readonly IGuestRepository Guest = new GuestRepository(); | ||
public static readonly IGuestAnswerRepository GuestAnswer = new GuestAnswerRepository(); | ||
public static readonly IPollRepository Poll = new PollRepository(); | ||
public static readonly IQuestionRepository Question = new QuestionRepository(); | ||
public static readonly IStaffRepository Staff = new StaffRepository(); | ||
public static readonly IUserRepository User = new UserRepository(); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using Anketbaz.Database.Database; | ||
|
||
namespace Anketbaz.Data.Logical | ||
{ | ||
public static class DatabaseService | ||
{ | ||
|
||
public static staff CheckStaffAuth(long staffId, string authKey, long compId) | ||
{ | ||
return | ||
EntityConnectionService.Staff.GetSingle( | ||
x => x.compid.Equals(compId) && x.staffid.Equals(staffId) && x.authkey.Equals(authKey)); | ||
} | ||
public static user CheckUserAuth(long userid, string authKey) | ||
{ | ||
return | ||
EntityConnectionService.User.GetSingle( | ||
x => x.userid.Equals(userid) && x.authkey.Equals(authKey)); | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Anketbaz.Data.Models; | ||
using Anketbaz.Database.Database; | ||
using Anketbaz.Database.Helper; | ||
using Newtonsoft.Json; | ||
using NPOI.SS.UserModel; | ||
using NPOI.XSSF.UserModel; | ||
using Anketbaz.Database.Log; | ||
|
||
namespace Anketbaz.Data | ||
{ | ||
public class Exporter | ||
{ | ||
public static string PollExportExcel(long ownerid, string ownerType, long pollId) | ||
{ | ||
Log.Info("GetData Started"); | ||
|
||
poll pollMaster = EntityConnectionService.Poll.GetSingle( | ||
x => x.ownerid.Equals(ownerid) && x.ownertype.Equals(ownerType) && x.pollid.Equals(pollId)); | ||
|
||
if (pollMaster == null) | ||
return Helper.GetResult(false, "0x0012"); | ||
|
||
IList<guest> guestList = EntityConnectionService.Guest.GetList( | ||
x => x.ownerid.Equals(ownerid) && x.ownertype.Equals(ownerType) && x.pollid.Equals(pollId)); | ||
|
||
IList<guestanswer> guestAnswers = EntityConnectionService.GuestAnswer.GetList( | ||
x => x.ownerid.Equals(ownerid) && x.ownertype.Equals(ownerType) && x.pollid.Equals(pollId)); | ||
|
||
IList<question> pollQuestions = EntityConnectionService.Question.GetList( | ||
x => x.ownerid.Equals(ownerid) && x.ownertype.Equals(ownerType) && x.pollid.Equals(pollId)) | ||
.OrderBy(x => x.questionid) | ||
.ToList(); | ||
|
||
IList<answer> pollAnswers = EntityConnectionService.Answer.GetList( | ||
x => x.ownerid.Equals(ownerid) && x.ownertype.Equals(ownerType) && x.pollid.Equals(pollId)); | ||
|
||
Log.Info("GetData Ended"); | ||
Log.Info("Export Started!"); | ||
|
||
string base64Data; | ||
|
||
DataTable dataTable = new DataTable(); //verileri kaydetmek icin datatable | ||
|
||
List<dynamic> fieldList = JsonConvert.DeserializeObject<List<dynamic>>(pollMaster.fielddata); //Bu anketin tum alanlarini parcala | ||
|
||
List<object> headerParams = new List<object>(); //basliklar icin headerparameters | ||
|
||
Log.Info("Header Creating!"); | ||
for (int i = 0; i < fieldList.Count; i++) //tum alanlar icinde don ve kolonlari belirle | ||
{ | ||
dataTable.Columns.Add(fieldList[i].FieldCode.ToString(), typeof(string)); //kolonlarin adlari | ||
headerParams.Add(fieldList[i].FieldTitle.ToString()); //kolonlarin icerikleri | ||
} | ||
|
||
for (int i = 0; i < pollQuestions.Count; i++) //tum sorular icinde don ve kolonlari belirle | ||
{ | ||
dataTable.Columns.Add(pollQuestions[i].questionid.ToString(), typeof(string)); //kolonlarin adlari | ||
headerParams.Add(pollQuestions[i].content); //kolonlarin icerikleri | ||
} | ||
dataTable.Rows.Add(headerParams.ToArray()); //basliklari tabloya ekle | ||
|
||
Log.Info("Header Created!"); | ||
|
||
Log.Info("Guests Creating!"); | ||
for (int i = 0; i < guestList.Count; i++) | ||
{ | ||
|
||
long guestId = guestList[i].guestid; //anket yapilan kisinin idsi | ||
Log.Info(string.Format("Start:{0}", guestId)); | ||
|
||
List<guestanswer> localGuestAnswers = | ||
guestAnswers.Where( | ||
x => x.guestid.Equals(guestId)).ToList(); | ||
List<object> guestData = new List<object>(); | ||
for (int j = 0; j < dataTable.Columns.Count; j++) | ||
{ | ||
if (j < fieldList.Count) | ||
{ | ||
//field icin burasi | ||
List<dynamic> guestFieldData = JsonConvert.DeserializeObject<List<dynamic>>(guestList[i].fielddata); //anket yapilan kisinin sadece alanlari | ||
for (int k = 0; k < guestFieldData.Count; k++)//bu anketi yapan kullanicinin alanlarini almak icin don | ||
{ | ||
if (dataTable.Columns[j].ColumnName == guestFieldData[k].FieldCode.ToString()) //bu alanin kodu kolonun koduna esitse yani veri buraya gelmeli ise | ||
{ | ||
guestData.Add(guestFieldData[k].FieldValue.ToString()); //bulunan veriyi anket yapilan kullanicinin verilerinin icine ekle. | ||
break;//ilgili alan bulundugu icin donguden cikilabilir. | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
//soru icin burasi | ||
|
||
localGuestAnswers = | ||
localGuestAnswers.Where(x => x.questionid.ToString() == (dataTable.Columns[j].ColumnName)).ToList(); | ||
string cellData = string.Empty; | ||
|
||
for (int k = 0; k < localGuestAnswers.Count; k++) | ||
{ | ||
answer cellAnswer = | ||
pollAnswers.FirstOrDefault(x => x.answerid.Equals(localGuestAnswers[k].answerid)); | ||
if (cellAnswer != null) | ||
cellData += cellAnswer.content + ","; | ||
guestAnswers.Remove(localGuestAnswers[k]); | ||
} | ||
|
||
cellData = cellData.Trim(','); | ||
guestData.Add(cellData); | ||
|
||
} | ||
} | ||
|
||
dataTable.Rows.Add(guestData.ToArray());//tum satirlari datatable a ekle | ||
|
||
Log.Info(string.Format("End:{0}", guestId)); | ||
} | ||
Log.Info("Guests Created!"); | ||
Log.Info("Ms Creating!"); | ||
using (MemoryStream memoryStream = new MemoryStream()) | ||
{ | ||
IWorkbook wb = new XSSFWorkbook(); | ||
ISheet sheet = wb.CreateSheet("Sheet1"); | ||
ICreationHelper cH = wb.GetCreationHelper(); | ||
|
||
var font = wb.CreateFont(); | ||
font.FontHeightInPoints = 11; | ||
font.FontName = "Calibri"; | ||
font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold; | ||
|
||
for (int i = 0; i < dataTable.Rows.Count; i++) | ||
{ | ||
IRow row = sheet.CreateRow(i); | ||
for (int j = 0; j < dataTable.Columns.Count; j++) | ||
{ | ||
ICell cell = row.CreateCell(j); | ||
if (i == 0) cell.CellStyle.SetFont(font); | ||
cell.SetCellValue(cH.CreateRichTextString(dataTable.Rows[i].ItemArray[j].ToString())); | ||
} | ||
} | ||
wb.Write(memoryStream); | ||
base64Data = Convert.ToBase64String(memoryStream.ToArray()); | ||
} | ||
|
||
Log.Info("Export Ended"); | ||
|
||
return Helper.GetResult(true, base64Data); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.