public static ContractTemplateViewModel MapToContractTemplateRoomViewModel(ContractTemplate sourcePrimary, List <TemplateRoomField> sourceSecondary) { var destination = AutoMapper.Mapper.Map <ContractTemplate, ContractTemplateViewModel>(sourcePrimary); MapToRoomFieldViewModel(sourceSecondary, destination.RoomFields); return(destination); }
public async Task Test_GetContractTemplates_sucess() { //Arrange var template = new ContractTemplate() { Id = 1, IsActive = true, Name = "T1", IsDeleted = false }; var baseResult = new BaseResult <List <ContractTemplate> >() { Result = new List <ContractTemplate>() { template } }; var pred = new Func <ContractTemplate, bool>(x => x.IsActive && !x.IsDeleted); iContractTemplateLibrary.Setup ( x => x.GetListByPredicate(It.Is <Func <ContractTemplate, bool> >(y => y.GetType() == pred.GetType())) ) .Returns(Task.FromResult(baseResult)); //Act var result = templateRepository.GetContractTemplates(); //Assert Assert.IsTrue(result.Result is BaseResult <List <ContractTemplate> >); Assert.IsTrue(result.Result.Result.Any(x => x.Id == template.Id)); }
public async Task Test_ContractTemplate_CRUD() { #region Arrange var tmpArticle = await FortnoxClient.ArticleConnector.CreateAsync(new Article() { Description = "TmpArticle" }); #endregion Arrange var connector = FortnoxClient.ContractTemplateConnector; #region CREATE var newContractTemplate = new ContractTemplate() { ContractLength = 4, Continuous = false, InvoiceInterval = 3, InvoiceRows = new List <ContractTemplateInvoiceRow>() { new ContractTemplateInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10 } }, TemplateName = "TestTemplate", }; var createdContractTemplate = await connector.CreateAsync(newContractTemplate); Assert.AreEqual("TestTemplate", createdContractTemplate.TemplateName); #endregion CREATE #region UPDATE createdContractTemplate.TemplateName = "UpdatedTestTemplate"; var updatedContractTemplate = await connector.UpdateAsync(createdContractTemplate); Assert.AreEqual("UpdatedTestTemplate", updatedContractTemplate.TemplateName); #endregion UPDATE #region READ / GET var retrievedContractTemplate = await connector.GetAsync(createdContractTemplate.TemplateNumber); Assert.AreEqual("UpdatedTestTemplate", retrievedContractTemplate.TemplateName); #endregion READ / GET #region DELETE //Not supported #endregion DELETE #region Delete arranged resources //FortnoxClient.ArticleConnector.Delete(tmpArticle.ArticleNumber); #endregion Delete arranged resources }
public async Task TestGetPublishedTemplatesForContractCreation_sucess_OKResponse() { //Arrange var contractTemplate = new ContractTemplate() { Id = 1, IsActive = true, Name = "T1", IsDeleted = false, IsPublished = true }; var baseResult = new BaseResult <List <ContractTemplate> >() { Result = new List <ContractTemplate>() { contractTemplate } }; iTemplate.Setup(x => x.GetPublishedTemplatesForContract()).Returns(Task.FromResult(baseResult)); //Act var result = contractTemplatesController.GetPublishedTemplatesForContractCreation(); //Assert Assert.IsTrue(result.Result is OkObjectResult); Assert.AreEqual(((OkObjectResult)result.Result).StatusCode, 200); Assert.IsTrue(((OkObjectResult)result.Result).Value is BaseResult <List <ContractTemplate> >); }
/// <summary> /// 删除模板信息 /// </summary> /// <param name="contraTemplateID">合同模板ID</param> /// <returns></returns> public bool DeleteContraTemplate(string[] contraTemplateID) { try { ContractTemplate cm = new ContractTemplate(); var entitys = from ent in cm.GetTable().ToList() where contraTemplateID.Contains(ent.CONTRACTTEMPLATEID) select ent; if (entitys.Count() > 0) { foreach (var obj in entitys) { Delete(obj); } int i = dal.SaveContextChanges(); if (i > 0) { return(true); } } return(false); } catch (Exception ex) { Tracer.Debug("合同模板ContractTemplateBLL-DeleteContraTemplate" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(false); throw (ex); } }
/// <summary> /// 获取查询的模板信息 /// </summary> /// <param name="ContractTemplateName"></param> /// <param name="strID"></param> /// <returns></returns> public List <V_ContractTemplate> GetTemplateRoomInfosListBySearch(string ContractTemplateName, string strTitle, string strContractLevel) { ContractTemplate cm = new ContractTemplate(); var q = from p in cm.GetTable() select new V_ContractTemplate { contractTemplate = p }; if (!string.IsNullOrEmpty(ContractTemplateName)) { q = q.Where(s => ContractTemplateName.Contains(s.contractTemplate.CONTRACTTEMPLATENAME)); } if (!string.IsNullOrEmpty(strTitle)) { q = q.Where(s => strTitle.Contains(s.contractTemplate.CONTRACTTITLE)); } if (!string.IsNullOrEmpty(strContractLevel)) { q = q.Where(s => strContractLevel.Contains(s.contractTemplate.CONTRACTLEVEL)); } if (q.Count() > 0) { return(q.ToList <V_ContractTemplate>()); } return(null); }
public async Task TestGetRoomFieldsByTemplateId_sucess_OKResponse() { //Arrange var id = 1; var request = new IntegerEntityViewModel() { Id = id }; var template = new ContractTemplate() { Id = id, Name = "tem1", NameItemId = 1, IsActive = true, IsDeleted = false }; var field1 = new TemplateRoomField() { Name = "H1", FieldId = 1, IsActive = true, IsDeleted = true, Code = "cd100", IconPath = "sym100", IsConfigurable = true }; var field2 = new TemplateRoomField() { Name = "H2", FieldId = 2, IsActive = true, IsDeleted = false, Code = "cd200", IconPath = "sym200", IsConfigurable = true, }; var fieldsResult = new BaseResult <List <TemplateRoomField> >() { Result = new List <TemplateRoomField>() { field1, field2 } }; iTemplate.Setup(x => x.GetTemplateRoomFields(It.IsAny <int>(), It.Is <bool>(y => !y))).Returns(Task.FromResult(fieldsResult)); var templateResult = new BaseResult <ContractTemplate>() { Result = template }; iTemplate.Setup(x => x.GetContractTemplateByID(It.IsAny <int>())).Returns(Task.FromResult(templateResult)); //Act var result = contractTemplatesController.GetRoomFields(request); //Assert Assert.IsTrue(result.Result is OkObjectResult); Assert.AreEqual(((OkObjectResult)result.Result).StatusCode, 200); Assert.IsTrue(((OkObjectResult)result.Result).Value is BaseResult <ContractTemplateViewModel>); }
/// <summary> /// 根据模板ID获取模板信息 /// </summary> /// <param name="contractTemplateID">模板ID</param> /// <returns>返回结果</returns> public T_OA_CONTRACTTEMPLATE GetContractTemplateById(string contractTemplateID) { ContractTemplate cm = new ContractTemplate(); var entity = from p in cm.GetTable() where p.CONTRACTTEMPLATEID == contractTemplateID select p; return(entity.Count() > 0 ? entity.FirstOrDefault() : null); }
public List <string> GetTemplateRoomNameInfos() { ContractTemplate cm = new ContractTemplate(); var query = from p in cm.GetTable() orderby p.CREATEDATE descending select p.CONTRACTTEMPLATENAME; return(query.ToList <string>()); }
/// <summary> /// 获取所有的模板信息 /// </summary> /// <returns></returns> public List <T_OA_CONTRACTTEMPLATE> GetTemplateRooms() { ContractTemplate cm = new ContractTemplate(); var query = from p in cm.GetTable() orderby p.CREATEDATE descending select p; return(query.ToList <T_OA_CONTRACTTEMPLATE>()); }
/// <summary> /// 获取某一类型的模板名称 /// </summary> /// <param name="StrContractTemplateType"></param> /// <returns></returns> public List <T_OA_CONTRACTTEMPLATE> GetContractTemplateInfosByContractType(string StrContractTemplateType) { ContractTemplate cm = new ContractTemplate(); var query = from p in cm.GetTable() where p.T_OA_CONTRACTTYPE.CONTRACTTYPEID == StrContractTemplateType select p; return(query.ToList <T_OA_CONTRACTTEMPLATE>()); }
public static Contract[] GenerateContracts(int contracts) { int team_size = Company.MyCompany == null ? 1 : Company.MyCompany.TeamSize; //int reputation = Company.MyCompany == null ? Character.MyCharacter.Reputation : Company.MyCompany.Reputation; //reputation = Mathf.Clamp(reputation, 0, 100); int reputation = 100; Contract[] generated_contracts = new Contract[contracts]; int char_name_val = Character.MyCharacter.Name.Aggregate(0, (current, c) => current + c); Random.InitState(TimeManager.Week * TimeManager.Year * (char_name_val + 1)); int contract_difficulty = team_size == 1 ? 1 : Mathf.CeilToInt(Mathf.Log(team_size, 2.0f)); Debug.Log(contract_difficulty); for (int i = 0; i < generated_contracts.Length; i++) { int days_to_complete = Random.Range(7, 28); var template = ContractTemplate.GetRandomTemplate(); SkillLevel[] skills_needed = new SkillLevel[template.SkillsNeeded.Length]; for (int j = 0; j < skills_needed.Length; j++) { int skill_sum = 0; for (int d = 0; d < days_to_complete; d++) { skill_sum += contract_difficulty * Random.Range(2, 8); } skills_needed[j] = new SkillLevel(template.SkillsNeeded[j], skill_sum); } var contract_reqs = new SkillList(skills_needed); int payout = Mathf.CeilToInt(skills_needed.Sum(x => x.Level) * 8 * Random.Range(0.8f, 1.2f)); if (reputation < 10) { payout = Mathf.CeilToInt(payout * 0.5f); } if (reputation > 90) { payout = Mathf.CeilToInt(payout * 2.0f); } payout = 10 * ((payout + 9) / 10); generated_contracts[i] = new Contract( template.ContractName, contract_reqs, days_to_complete, payout, contract_difficulty * 2); } return(generated_contracts); }
public async Task TestGetRoomFieldsByTemplateId_failed_Error_2() { //Arrange var id = 1; var request = new IntegerEntityViewModel() { Id = id }; var template = new ContractTemplate() { Id = id, Name = "tem1", NameItemId = 1, IsActive = true, IsDeleted = false }; var field1 = new TemplateRoomField() { Name = "H1", FieldId = 1, IsActive = true, IsDeleted = true, Code = "cd100", IconPath = "sym100", IsConfigurable = true }; var field2 = new TemplateRoomField() { Name = "H2", FieldId = 2, IsActive = true, IsDeleted = false, Code = "cd200", IconPath = "sym200", IsConfigurable = true, }; var templateResult = new BaseResult <ContractTemplate>() { Result = template }; iTemplate.Setup(x => x.GetContractTemplateByID(It.IsAny <int>())).Returns(Task.FromResult(templateResult)); var baseResult = new BaseResult <List <TemplateRoomField> >() { IsError = true, ExceptionMessage = Common.GetMockException() }; iTemplate.Setup(x => x.GetTemplateRoomFields(It.IsAny <int>(), It.Is <bool>(y => !y))).Returns(Task.FromResult(baseResult)); //Act var result = contractTemplatesController.GetRoomFields(request); //Assert Assert.IsTrue(result.Result is StatusCodeResult); Assert.AreEqual(((StatusCodeResult)result.Result).StatusCode, 500); }
public void UpdateTemplate(ContractTemplate template) { using (var scope = ConnectionScope.GetExistOrCreate()) { CPQuery.Create(@" UPDATE dbo.Geek_ContractTemplate SET TemplateContent=@TemplateContent WHERE ContractTemplateGUID=@ContractTemplateGUID ", template).ExecuteNonQuery(); } }
/// <summary> /// 检查是否存在该模板合同 /// </summary> /// <param name="ContractTemplate">模板名称</param> /// <param name="ContractTemplateID">模板编号</param> /// <returns></returns> public bool IsExistContractTemplate(string templateName, string contractType, string contractLelve, string templateTitle) { ContractTemplate cm = new ContractTemplate(); bool IsExist = false; var q = from cnt in cm.GetTable() where cnt.CONTRACTTEMPLATENAME == templateName && cnt.CREATECOMPANYID == contractType && cnt.CONTRACTLEVEL == contractLelve && cnt.CONTRACTTITLE == templateTitle || cnt.CONTRACTTITLE == templateTitle orderby cnt.CREATEUSERID select cnt; if (q.Count() > 0) { IsExist = true; } return(IsExist); }
public async Task Test_ContractTemplate_Find() { #region Arrange var tmpArticle = await FortnoxClient.ArticleConnector.CreateAsync(new Article() { Description = "TmpArticle" }); #endregion Arrange var connector = FortnoxClient.ContractTemplateConnector; var marks = TestUtils.RandomString(); var newContractTemplate = new ContractTemplate() { ContractLength = 4, Continuous = false, InvoiceInterval = 3, InvoiceRows = new List <ContractTemplateInvoiceRow>() { new ContractTemplateInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10 } }, }; for (var i = 0; i < 5; i++) { newContractTemplate.TemplateName = marks + i; await connector.CreateAsync(newContractTemplate); } var searchSettings = new ContractTemplateSearch(); searchSettings.LastModified = TestUtils.Recently; var templates = await connector.FindAsync(searchSettings); Assert.AreEqual(5, templates.Entities.Count(c => c.TemplateName.StartsWith(marks))); //No delete supported }
public void Test_ContractTemplate_Find() { #region Arrange var tmpArticle = new ArticleConnector().Create(new Article() { Description = "TmpArticle" }); #endregion Arrange IContractTemplateConnector connector = new ContractTemplateConnector(); var marks = TestUtils.RandomString(); var newContractTemplate = new ContractTemplate() { ContractLength = 4, Continuous = false, InvoiceInterval = 3, InvoiceRows = new List <ContractTemplateInvoiceRow>() { new ContractTemplateInvoiceRow() { ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10 } }, }; for (int i = 0; i < 5; i++) { newContractTemplate.TemplateName = marks + i; connector.Create(newContractTemplate); MyAssert.HasNoError(connector); } connector.LastModified = DateTime.Now.AddMinutes(-5); var templates = connector.Find(); MyAssert.HasNoError(connector); Assert.AreEqual(5, templates.Entities.Count(c => c.TemplateName.StartsWith(marks))); //No delete supported }
public static async Task <SingleResource <ContractTemplate> > UpdateContractTemplateAsync( FortnoxApiRequest request, ContractTemplate contractTemplate ) { var apiRequest = new FortnoxApiClientRequest <SingleResource <ContractTemplate> >( HttpMethod.Put, request.AccessToken, request.ClientSecret, $"{ApiEndpoints.ContractTemplates}/{contractTemplate.TemplateNumber}" ) { Data = new SingleResource <ContractTemplate>() { Data = contractTemplate } }; return(await FortnoxAPIClient.CallAsync(apiRequest)); }
public async Task <ContractTemplate> UpdateAsync(ContractTemplate contractTemplate) { return(await BaseUpdate(contractTemplate, contractTemplate.TemplateNumber).ConfigureAwait(false)); }
/// <summary> /// 获取到名称为conTempName的模版的信息 /// </summary> /// <param name="conTempName"></param> /// <returns></returns> public static ContractTemplate GetContractTemplate(String conTempName) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; ContractTemplate conTemp = null; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = GET_CONTRACT_TEMPLATE_ID_STR; cmd.Parameters.AddWithValue("@Name", conTempName); // 员工编号 MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); if (sqlRead.Read()) { conTemp = new ContractTemplate(); conTemp.TempId = int.Parse(sqlRead["id"].ToString()); conTemp.Name = sqlRead["name"].ToString(); // 5个栏目信息 // conTemp.ColumnCount = 5; List <String> columns = new List <String>(); /* * columns.Add(sqlRead["column1"].ToString()); * columns.Add(sqlRead["column2"].ToString()); * columns.Add(sqlRead["column3"].ToString()); * columns.Add(sqlRead["column4"].ToString()); * columns.Add(sqlRead["column5"].ToString()); */ for (int cnt = 1; cnt <= 5; cnt++) { String strColumn = "column" + cnt.ToString(); columns.Add(sqlRead[strColumn].ToString()); } conTemp.ColumnNames = columns; // 8个签字人信息 // conTemp.SignCount = 8; List <SignatureTemplate> signatures = new List <SignatureTemplate>(); for (int cnt = 1; cnt <= 8; cnt++) { String strSignInfo = "signinfo" + cnt.ToString(); String strSignId = "signid" + cnt.ToString(); String strSignName = "signname" + cnt.ToString(); String strDepartmentId = "department" + cnt.ToString(); String strDepartmentName = "department" + cnt.ToString(); String strCanView = "canview" + cnt.ToString(); String strCanDownload = "candownload" + cnt.ToString(); SignatureTemplate signDatas = new SignatureTemplate(); signDatas.SignInfo = sqlRead[strSignInfo].ToString(); Employee employee = new Employee(); employee.Id = int.Parse(sqlRead[strSignId].ToString()); employee.Name = sqlRead[strSignName].ToString(); Department department = new Department(); department.Id = int.Parse(sqlRead[strDepartmentId].ToString()); department.Name = sqlRead[strDepartmentName].ToString(); employee.Department = department; signDatas.SignEmployee = employee; signDatas.CanView = int.Parse(sqlRead[strCanView].ToString()); signDatas.CanDownload = int.Parse(sqlRead[strCanDownload].ToString()); signatures.Add(signDatas); } conTemp.SignDatas = signatures; } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(conTemp); }
public async Task <ContractTemplate> UpdateAsync(ContractTemplate contractTemplate) { return(await BaseUpdate(contractTemplate, contractTemplate.TemplateNumber)); }
/// <summary> /// This method first connects to the Organization service. Afterwards, /// a Contract Template and several Contracts are created, demonstrating how to /// create and work with the Contract entity. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetWorkingWithContracts1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); CreateRequiredRecords(); #region Create Contract Template // First, attempt to retrieve the Contract Template. Otherwise, // create the template. QueryExpression templateQuery = new QueryExpression() { EntityName = ContractTemplate.EntityLogicalName, ColumnSet = new ColumnSet("contracttemplateid"), Criteria = { Conditions = { new ConditionExpression("abbreviation", ConditionOperator.Equal, "SCT") } } }; EntityCollection ec = _serviceProxy.RetrieveMultiple(templateQuery); if (ec.Entities.Count > 0) { _contractTemplateId = ec.Entities[0].Id; Console.Write("Template retrieved, "); } else { ContractTemplate contractTemplate = new ContractTemplate() { Name = "Sample Contract Template", BillingFrequencyCode = new OptionSetValue((int)ContractTemplateBillingFrequencyCode.Monthly), Abbreviation = "SCT", AllotmentTypeCode = new OptionSetValue((int)ContractTemplateAllotmentTypeCode.NumberofCases), EffectivityCalendar = "--------+++++++++---------------+++++++++---------------+++++++++---------------+++++++++---------------+++++++++-------------------------------------------------------" }; _contractTemplateId = _serviceProxy.Create(contractTemplate); Console.Write("Template created, "); } #endregion #region Create Contract // Create a Contract from the Contract Template. Contract contract = new Contract() { Title = "Sample Contract", ContractTemplateId = new EntityReference { Id = _contractTemplateId, LogicalName = ContractTemplate.EntityLogicalName }, CustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, BillingCustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, ActiveOn = new DateTime(2015, 1, 1), ExpiresOn = new DateTime(2020, 1, 1), BillingStartOn = new DateTime(2015, 1, 1), BillingEndOn = new DateTime(2020, 1, 1) }; _contractId = _serviceProxy.Create(contract); Console.Write("parent contract created, "); // Create a contract line item. ContractDetail contractLineItem = new ContractDetail() { Title = "Sample Contract Line Item", ContractId = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, CustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, ActiveOn = new DateTime(2015, 1, 1), ExpiresOn = new DateTime(2020, 1, 1), Price = new Money(20.0M), TotalAllotments = 20 }; _serviceProxy.Create(contractLineItem); Console.Write("contract line attached, "); #endregion #region Clone contract twice //<snippetCloneContract> // Create the first clone of the contract. CloneContractRequest cloneRequest = new CloneContractRequest() { ContractId = _contractId, IncludeCanceledLines = false }; CloneContractResponse cloneResponse = (CloneContractResponse)_serviceProxy.Execute(cloneRequest); _firstCloneId = ((Contract)cloneResponse.Entity).ContractId.Value; //</snippetCloneContract> Console.Write("first clone created, "); // Create the second clone of the contract. cloneRequest = new CloneContractRequest() { ContractId = _contractId, IncludeCanceledLines = true }; cloneResponse = (CloneContractResponse)_serviceProxy.Execute(cloneRequest); _secondCloneId = ((Contract)cloneResponse.Entity).ContractId.Value; Console.Write("second clone created. \n"); // Retrieve all Contracts. QueryExpression contractQuery = new QueryExpression() { EntityName = Contract.EntityLogicalName, ColumnSet = new ColumnSet("contractid"), Criteria = { Conditions = { new ConditionExpression("customerid", ConditionOperator.Equal, _accountId) } } }; EntityCollection contracts = _serviceProxy.RetrieveMultiple(contractQuery); // Display the retrieved Contract Ids. for (int i = 0; i < contracts.Entities.Count; i++) { Console.WriteLine("Retrieved contract with Id: {0}", ((Contract)contracts.Entities[i]).ContractId); } #endregion #region Deactivate a cloned contract // In order to deactivate a contract (put it on hold), it is first // necessary to invoice the contract. SetStateRequest setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _firstCloneId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Invoiced), Status = new OptionSetValue(2) }; _serviceProxy.Execute(setStateRequest); Console.Write("Contract invoiced, "); // Now that the contract has been invoiced, it is possible to put // the contract on hold. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _firstCloneId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.OnHold), Status = new OptionSetValue(4) }; _serviceProxy.Execute(setStateRequest); Console.Write("and put on hold.\n"); #endregion #region Renew an invoiced contract // In order to renew a contract, it must be invoiced first, and // then canceled. //<snippetSetStateForContract> // Invoice the contract. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Invoiced), Status = new OptionSetValue(3) }; _serviceProxy.Execute(setStateRequest); //</snippetSetStateForContract> Console.Write("Contract invoiced, "); //<snippetCancelContract> // Cancel the contract. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Canceled), Status = new OptionSetValue(5) }; _serviceProxy.Execute(setStateRequest); //</snippetCancelContract> Console.Write("canceled, "); //<snippetRenewContract> // Renew the canceled contract. RenewContractRequest renewRequest = new RenewContractRequest() { ContractId = _contractId, IncludeCanceledLines = true, Status = 1 }; RenewContractResponse renewResponse = (RenewContractResponse)_serviceProxy.Execute(renewRequest); // Retrieve Id of renewed contract. _renewedId = ((Contract)renewResponse.Entity).ContractId.Value; //</snippetRenewContract> // Display the Id of the renewed contract. Console.WriteLine("and renewed."); #endregion DeleteRequiredRecords(promptforDelete); } //</snippetWorkingWithContracts1> } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// 插入员工信息 /// </summary> /// <param name="conTemp">待插入的会签单模版</param> /// <returns></returns> public static bool InsertContractTemplate(ContractTemplate conTemp) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int count = -1; // 受影响行数 try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = INSERT_CONTRACT_TEMPLATE_STR; cmd.Parameters.AddWithValue("@Name", conTemp.Name); cmd.Parameters.AddWithValue("@CreateDate", System.DateTime.Now); // cmd.Parameters.AddWithValue("@CreateDate", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); /// 5个栏目信息 /* * cmd.Parameters.AddWithValue("@Column_1", conTemp.ColumnDatas[0]); * cmd.Parameters.AddWithValue("@Column_2", conTemp.ColumnDatas[1]); * cmd.Parameters.AddWithValue("@Column_3", conTemp.ColumnDatas[2]); * cmd.Parameters.AddWithValue("@Column_4", conTemp.ColumnDatas[3]); * cmd.Parameters.AddWithValue("@Column_5", conTemp.ColumnDatas[4]); */ for (int cnt = 0; cnt < 5; cnt++) { String strColumn = "@Column_" + (cnt + 1).ToString( ); cmd.Parameters.AddWithValue(strColumn, conTemp.ColumnNames[cnt]); } /// 8项签字信息 /* * cmd.Parameters.AddWithValue("@SignInfo_1", conTemp.SignDatas[0].SignInfo); * cmd.Parameters.AddWithValue("@SignId_1", conTemp.SignDatas[0].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_2", conTemp.SignDatas[1].SignInfo); * cmd.Parameters.AddWithValue("@SignId_2", conTemp.SignDatas[1].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_3", conTemp.SignDatas[2].SignInfo); * cmd.Parameters.AddWithValue("@SignId_3", conTemp.SignDatas[2].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_4", conTemp.SignDatas[3].SignInfo); * cmd.Parameters.AddWithValue("@SignId_4", conTemp.SignDatas[3].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_5", conTemp.SignDatas[4].SignInfo); * cmd.Parameters.AddWithValue("@SignId_5", conTemp.SignDatas[4].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_6", conTemp.SignDatas[5].SignInfo); * cmd.Parameters.AddWithValue("@SignId_6", conTemp.SignDatas[5].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_7", conTemp.SignData[6].SignInfo); * cmd.Parameters.AddWithValue("@SignId_7", conTemp.SignData[6].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_8", conTemp.SignData[7].SignInfo); * cmd.Parameters.AddWithValue("@SignId_8", conTemp.SignData[7].SignId); */ for (int cnt = 0; cnt < 8; cnt++) { String strSignInfo = "@SignInfo_" + (cnt + 1).ToString(); String strSignId = "@SignId_" + (cnt + 1).ToString(); String strSignLevel = @"SignLevel_" + (cnt + 1).ToString(); String strCanView = "@CanView_" + (cnt + 1).ToString(); String strCanDownload = "@CanDownload_" + (cnt + 1).ToString(); cmd.Parameters.AddWithValue(strSignInfo, conTemp.SignDatas[cnt].SignInfo); cmd.Parameters.AddWithValue(strSignId, conTemp.SignDatas[cnt].SignEmployee.Id); cmd.Parameters.AddWithValue(strSignLevel, conTemp.SignDatas[cnt].SignLevel); cmd.Parameters.AddWithValue(strCanView, conTemp.SignDatas[cnt].CanView); cmd.Parameters.AddWithValue(strCanDownload, conTemp.SignDatas[cnt].CanDownload); } count = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); con.Dispose(); if (count == 1) // 插入成功后的受影响行数为1 { Console.WriteLine("插入会签单模版成功"); return(true); } else { Console.WriteLine("插入会签单模版失败"); return(false); } } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
/// <summary> /// Updates a contractTemplate /// </summary> /// <param name="contractTemplate">The contractTemplate to update</param> /// <returns>The updated contractTemplate</returns> public ContractTemplate Update(ContractTemplate contractTemplate) { return(UpdateAsync(contractTemplate).Result); }
/// <summary> /// This method first connects to the Organization service. Afterwards, /// a Contract Template and several Contracts are created, demonstrating how to /// create and work with the Contract entity. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetWorkingWithContracts1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); CreateRequiredRecords(); #region Create Contract Template // First, attempt to retrieve the Contract Template. Otherwise, // create the template. QueryExpression templateQuery = new QueryExpression() { EntityName = ContractTemplate.EntityLogicalName, ColumnSet = new ColumnSet("contracttemplateid"), Criteria = { Conditions = { new ConditionExpression("abbreviation", ConditionOperator.Equal, "SCT") } } }; EntityCollection ec = _serviceProxy.RetrieveMultiple(templateQuery); if (ec.Entities.Count > 0) { _contractTemplateId = ec.Entities[0].Id; Console.Write("Template retrieved, "); } else { ContractTemplate contractTemplate = new ContractTemplate() { Name = "Sample Contract Template", BillingFrequencyCode = new OptionSetValue((int)ContractTemplateBillingFrequencyCode.Monthly), Abbreviation = "SCT", AllotmentTypeCode = new OptionSetValue((int)ContractTemplateAllotmentTypeCode.NumberofCases), EffectivityCalendar = "--------+++++++++---------------+++++++++---------------+++++++++---------------+++++++++---------------+++++++++-------------------------------------------------------" }; _contractTemplateId = _serviceProxy.Create(contractTemplate); Console.Write("Template created, "); } #endregion #region Create Contract // Create a Contract from the Contract Template. Contract contract = new Contract() { Title = "Sample Contract", ContractTemplateId = new EntityReference { Id = _contractTemplateId, LogicalName = ContractTemplate.EntityLogicalName }, CustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, BillingCustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, ActiveOn = new DateTime(2015, 1, 1), ExpiresOn = new DateTime(2020, 1, 1), BillingStartOn = new DateTime(2015, 1, 1), BillingEndOn = new DateTime(2020, 1, 1) }; _contractId = _serviceProxy.Create(contract); Console.Write("parent contract created, "); // Create a contract line item. ContractDetail contractLineItem = new ContractDetail() { Title = "Sample Contract Line Item", ContractId = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, CustomerId = new EntityReference { Id = _accountId, LogicalName = Account.EntityLogicalName }, ActiveOn = new DateTime(2015, 1, 1), ExpiresOn = new DateTime(2020, 1, 1), Price = new Money(20.0M), TotalAllotments = 20 }; _serviceProxy.Create(contractLineItem); Console.Write("contract line attached, "); #endregion #region Clone contract twice //<snippetCloneContract> // Create the first clone of the contract. CloneContractRequest cloneRequest = new CloneContractRequest() { ContractId = _contractId, IncludeCanceledLines = false }; CloneContractResponse cloneResponse = (CloneContractResponse)_serviceProxy.Execute(cloneRequest); _firstCloneId = ((Contract)cloneResponse.Entity).ContractId.Value; //</snippetCloneContract> Console.Write("first clone created, "); // Create the second clone of the contract. cloneRequest = new CloneContractRequest() { ContractId = _contractId, IncludeCanceledLines = true }; cloneResponse = (CloneContractResponse)_serviceProxy.Execute(cloneRequest); _secondCloneId = ((Contract)cloneResponse.Entity).ContractId.Value; Console.Write("second clone created. \n"); // Retrieve all Contracts. QueryExpression contractQuery = new QueryExpression() { EntityName = Contract.EntityLogicalName, ColumnSet = new ColumnSet("contractid"), Criteria = { Conditions = { new ConditionExpression("customerid", ConditionOperator.Equal, _accountId) } } }; EntityCollection contracts = _serviceProxy.RetrieveMultiple(contractQuery); // Display the retrieved Contract Ids. for (int i = 0; i < contracts.Entities.Count; i++) { Console.WriteLine("Retrieved contract with Id: {0}", ((Contract)contracts.Entities[i]).ContractId); } #endregion #region Deactivate a cloned contract // In order to deactivate a contract (put it on hold), it is first // necessary to invoice the contract. SetStateRequest setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _firstCloneId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Invoiced), Status = new OptionSetValue(2) }; _serviceProxy.Execute(setStateRequest); Console.Write("Contract invoiced, "); // Now that the contract has been invoiced, it is possible to put // the contract on hold. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _firstCloneId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.OnHold), Status = new OptionSetValue(4) }; _serviceProxy.Execute(setStateRequest); Console.Write("and put on hold.\n"); #endregion #region Renew an invoiced contract // In order to renew a contract, it must be invoiced first, and // then canceled. //<snippetSetStateForContract> // Invoice the contract. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Invoiced), Status = new OptionSetValue(3) }; _serviceProxy.Execute(setStateRequest); //</snippetSetStateForContract> Console.Write("Contract invoiced, "); //<snippetCancelContract> // Cancel the contract. setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = _contractId, LogicalName = Contract.EntityLogicalName }, State = new OptionSetValue((int)ContractState.Canceled), Status = new OptionSetValue(5) }; _serviceProxy.Execute(setStateRequest); //</snippetCancelContract> Console.Write("canceled, "); //<snippetRenewContract> // Renew the canceled contract. RenewContractRequest renewRequest = new RenewContractRequest() { ContractId = _contractId, IncludeCanceledLines = true, Status = 1 }; RenewContractResponse renewResponse = (RenewContractResponse)_serviceProxy.Execute(renewRequest); // Retrieve Id of renewed contract. _renewedId = ((Contract)renewResponse.Entity).ContractId.Value; //</snippetRenewContract> // Display the Id of the renewed contract. Console.WriteLine("and renewed."); #endregion DeleteRequiredRecords(promptforDelete); } //</snippetWorkingWithContracts1> } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Creates a new contractTemplate /// </summary> /// <param name="contractTemplate">The contractTemplate to create</param> /// <returns>The created contractTemplate</returns> public ContractTemplate Create(ContractTemplate contractTemplate) { return(CreateAsync(contractTemplate).Result); }
public async Task <ContractTemplate> CreateAsync(ContractTemplate contractTemplate) { return(await BaseCreate(contractTemplate)); }
public async Task <ContractTemplate> CreateAsync(ContractTemplate contractTemplate) { return(await BaseCreate(contractTemplate).ConfigureAwait(false)); }
public static bool ModifyContractTemplate(ContractTemplate conTemp) { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; int count = -1; try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = MODIFY_CONTRACT_TEMPLATE_STR; cmd.Parameters.AddWithValue("@Id", conTemp.TempId); cmd.Parameters.AddWithValue("@Name", conTemp.Name); /// 5个栏目信息 /* * cmd.Parameters.AddWithValue("@Column_1", conTemp.ColumnDatas[0]); * cmd.Parameters.AddWithValue("@Column_2", conTemp.ColumnDatas[1]); * cmd.Parameters.AddWithValue("@Column_3", conTemp.ColumnDatas[2]); * cmd.Parameters.AddWithValue("@Column_4", conTemp.ColumnDatas[3]); * cmd.Parameters.AddWithValue("@Column_5", conTemp.ColumnDatas[4]); */ for (int cnt = 0; cnt < 5; cnt++) { String strColumn = "@Column_" + (cnt + 1).ToString( ); cmd.Parameters.AddWithValue(strColumn, conTemp.ColumnNames[cnt]); } /// 8项签字信息 /* * cmd.Parameters.AddWithValue("@SignInfo_1", conTemp.SignDatas[0].SignInfo); * cmd.Parameters.AddWithValue("@SignId_1", conTemp.SignDatas[0].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_2", conTemp.SignDatas[1].SignInfo); * cmd.Parameters.AddWithValue("@SignId_2", conTemp.SignDatas[1].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_3", conTemp.SignDatas[2].SignInfo); * cmd.Parameters.AddWithValue("@SignId_3", conTemp.SignDatas[2].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_4", conTemp.SignDatas[3].SignInfo); * cmd.Parameters.AddWithValue("@SignId_4", conTemp.SignDatas[3].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_5", conTemp.SignDatas[4].SignInfo); * cmd.Parameters.AddWithValue("@SignId_5", conTemp.SignDatas[4].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_6", conTemp.SignDatas[5].SignInfo); * cmd.Parameters.AddWithValue("@SignId_6", conTemp.SignDatas[5].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_7", conTemp.SignData[6].SignInfo); * cmd.Parameters.AddWithValue("@SignId_7", conTemp.SignData[6].SignId); * * cmd.Parameters.AddWithValue("@SignInfo_8", conTemp.SignData[7].SignInfo); * cmd.Parameters.AddWithValue("@SignId_8", conTemp.SignData[7].SignId); */ for (int cnt = 0; cnt < 8; cnt++) { String strSignInfo = "@SignInfo_" + (cnt + 1).ToString(); String strSignId = "@SignId_" + (cnt + 1).ToString(); String strSignLevel = @"SignLevel_" + (cnt + 1).ToString(); String strCanView = "@CanView_" + (cnt + 1).ToString(); String strCanDownload = "@CanDownload_" + (cnt + 1).ToString(); cmd.Parameters.AddWithValue(strSignInfo, conTemp.SignDatas[cnt].SignInfo); cmd.Parameters.AddWithValue(strSignId, conTemp.SignDatas[cnt].SignEmployee.Id); cmd.Parameters.AddWithValue(strSignLevel, conTemp.SignDatas[cnt].SignLevel); cmd.Parameters.AddWithValue(strCanView, conTemp.SignDatas[cnt].CanView); cmd.Parameters.AddWithValue(strCanDownload, conTemp.SignDatas[cnt].CanDownload); } count = cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } if (count == 1) { Console.WriteLine("修改会签单信息" + conTemp.TempId.ToString() + "成功"); return(true); } else { Console.WriteLine("修改会签单信息" + conTemp.TempId.ToString() + "失败"); return(false); } }
private async Task <string> CheckContractTemplates() { StringBuilder content = new StringBuilder(); await _comparerSource.InitializeConnection(_iWriteToOutput, content); string operation = string.Format(Properties.OperationNames.CheckingContractTemplatesFormat2, Connection1.Name, Connection2.Name); content.AppendLine(_iWriteToOutput.WriteToOutputStartOperation(null, operation)); Task <List <ContractTemplate> > task1 = _comparerSource.GetContractTemplate1Async(); Task <List <ContractTemplate> > task2 = _comparerSource.GetContractTemplate2Async(); List <ContractTemplate> list1 = await task1; content.AppendLine(_iWriteToOutput.WriteToOutput(null, "Contract Templates in {0}: {1}", Connection1.Name, list1.Count())); List <ContractTemplate> list2 = await task2; content.AppendLine(_iWriteToOutput.WriteToOutput(null, "Contract Templates in {0}: {1}", Connection2.Name, list2.Count())); if (list1.Count == 0 && list2.Count == 0) { _iWriteToOutput.WriteToOutput(null, Properties.OrganizationComparerStrings.ThereIsNothingToCompare); _iWriteToOutput.WriteToOutputEndOperation(null, operation); return(null); } List <string> fieldsToCompare = new List <string>() { ContractTemplate.Schema.Attributes.abbreviation , ContractTemplate.Schema.Attributes.allotmenttypecode , ContractTemplate.Schema.Attributes.billingfrequencycode //, ContractTemplate.Schema.Attributes.componentstate , ContractTemplate.Schema.Attributes.contractservicelevelcode //, ContractTemplate.Schema.Attributes.contracttemplateid //, ContractTemplate.Schema.Attributes.contracttemplateidunique //, ContractTemplate.Schema.Attributes.createdby //, ContractTemplate.Schema.Attributes.createdon //, ContractTemplate.Schema.Attributes.createdonbehalfby , ContractTemplate.Schema.Attributes.description , ContractTemplate.Schema.Attributes.effectivitycalendar //, ContractTemplate.Schema.Attributes.importsequencenumber //, ContractTemplate.Schema.Attributes.introducedversion , ContractTemplate.Schema.Attributes.iscustomizable //, ContractTemplate.Schema.Attributes.ismanaged //, ContractTemplate.Schema.Attributes.modifiedby //, ContractTemplate.Schema.Attributes.modifiedon //, ContractTemplate.Schema.Attributes.modifiedonbehalfby , ContractTemplate.Schema.Attributes.name //, ContractTemplate.Schema.Attributes.organizationid //, ContractTemplate.Schema.Attributes.overriddencreatedon //, ContractTemplate.Schema.Attributes.overwritetime //, ContractTemplate.Schema.Attributes.solutionid //, ContractTemplate.Schema.Attributes.supportingsolutionid , ContractTemplate.Schema.Attributes.usediscountaspercentage //, ContractTemplate.Schema.Attributes.versionnumber }; List <string> xmlFieldsToCompare = new List <string>() { //ContractTemplate.Schema.Attributes.body //, ContractTemplate.Schema.Attributes.presentationxml //, ContractTemplate.Schema.Attributes.subjectpresentationxml }; FormatTextTableHandler tableOnlyExistsIn1 = new FormatTextTableHandler(); tableOnlyExistsIn1.SetHeader("Name", "Id"); FormatTextTableHandler tableOnlyExistsIn2 = new FormatTextTableHandler(); tableOnlyExistsIn2.SetHeader("Name", "Id"); Dictionary <Tuple <string, string>, List <string> > dictDifference = new Dictionary <Tuple <string, string>, List <string> >(); foreach (ContractTemplate template1 in list1) { { ContractTemplate template2 = list2.FirstOrDefault(template => template.Id == template1.Id); if (template2 != null) { continue; } } string name1 = template1.Name; tableOnlyExistsIn1.AddLine(name1, template1.Id.ToString()); this.ImageBuilder.AddComponentSolution1((int)ComponentType.ContractTemplate, template1.Id); } foreach (ContractTemplate template2 in list2) { { ContractTemplate template1 = list1.FirstOrDefault(template => template.Id == template2.Id); if (template1 != null) { continue; } } string name2 = template2.Name; tableOnlyExistsIn2.AddLine(name2, template2.Id.ToString()); this.ImageBuilder.AddComponentSolution2((int)ComponentType.ContractTemplate, template2.Id); } foreach (ContractTemplate template1 in list1) { ContractTemplate template2 = list2.FirstOrDefault(template => template.Id == template1.Id); if (template2 == null) { continue; } FormatTextTableHandler tabDiff = new FormatTextTableHandler(); tabDiff.SetHeader("Attribute", "Organization", "Value"); foreach (string fieldName in fieldsToCompare) { if (ContentCoparerHelper.IsEntityDifferentInField(template1, template2, fieldName)) { string str1 = EntityDescriptionHandler.GetAttributeString(template1, fieldName, Connection1); string str2 = EntityDescriptionHandler.GetAttributeString(template2, fieldName, Connection2); tabDiff.AddLine(fieldName, Connection1.Name, str1); tabDiff.AddLine(fieldName, Connection2.Name, str2); } } foreach (string fieldName in xmlFieldsToCompare) { string xml1 = template1.GetAttributeValue <string>(fieldName) ?? string.Empty; string xml2 = template2.GetAttributeValue <string>(fieldName) ?? string.Empty; if (!ContentCoparerHelper.CompareXML(xml1, xml2).IsEqual) { string reason = string.Empty; ContentCopareResult compare = ContentCoparerHelper.CompareXML(xml1.ToLower(), xml2.ToLower(), true); if (!compare.IsEqual) { reason = "InCase"; } else { reason = compare.GetCompareDescription(); } tabDiff.AddLine(fieldName, string.Empty, string.Format(Properties.OrganizationComparerStrings.FieldDifferenceReasonFormat3, Connection1.Name, Connection2.Name, reason)); } } if (tabDiff.Count > 0) { string name1 = template1.Name; var diff = tabDiff.GetFormatedLines(false); this.ImageBuilder.AddComponentDifferent((int)ComponentType.ContractTemplate, template1.Id, template2.Id, string.Join(Environment.NewLine, diff)); dictDifference.Add(Tuple.Create(name1, template1.Id.ToString()), diff); } } if (tableOnlyExistsIn1.Count > 0) { content .AppendLine() .AppendLine() .AppendLine() .AppendLine(new string('-', 150)) .AppendLine() .AppendLine(); content.AppendLine().AppendLine().AppendFormat("Contract Templates ONLY EXISTS in {0}: {1}", Connection1.Name, tableOnlyExistsIn1.Count); tableOnlyExistsIn1.GetFormatedLines(true).ForEach(e => content.AppendLine().Append((tabSpacer + e).TrimEnd())); } if (tableOnlyExistsIn2.Count > 0) { content .AppendLine() .AppendLine() .AppendLine() .AppendLine(new string('-', 150)) .AppendLine() .AppendLine(); content.AppendLine().AppendLine().AppendFormat("Contract Templates ONLY EXISTS in {0}: {1}", Connection2.Name, tableOnlyExistsIn2.Count); tableOnlyExistsIn2.GetFormatedLines(true).ForEach(e => content.AppendLine().Append((tabSpacer + e).TrimEnd())); } if (dictDifference.Count > 0) { content .AppendLine() .AppendLine() .AppendLine() .AppendLine(new string('-', 150)) .AppendLine() .AppendLine(); content.AppendLine().AppendLine().AppendFormat("Contract Templates DIFFERENT in {0} and {1}: {2}", Connection1.Name, Connection2.Name, dictDifference.Count); FormatTextTableHandler tableDifference = new FormatTextTableHandler(); tableDifference.SetHeader("Title", "Id"); foreach (KeyValuePair <Tuple <string, string>, List <string> > template in dictDifference) { tableDifference.CalculateLineLengths(template.Key.Item1, template.Key.Item2); } foreach (KeyValuePair <Tuple <string, string>, List <string> > template in dictDifference .OrderBy(w => w.Key.Item1) .ThenBy(w => w.Key.Item2) ) { content.AppendLine().Append(tabSpacer + tableDifference.FormatLine(template.Key.Item1, template.Key.Item2)); foreach (string str in template.Value) { content.AppendLine().Append(tabSpacer + tabSpacer + str); } } } if (tableOnlyExistsIn2.Count == 0 && tableOnlyExistsIn1.Count == 0 && dictDifference.Count == 0 ) { content.AppendLine("No difference in Contract Templates."); } content.AppendLine().AppendLine().AppendLine(_iWriteToOutput.WriteToOutputEndOperation(null, operation)); string fileName = EntityFileNameFormatter.GetDifferenceConnectionsForFieldFileName(_OrgOrgName, "Contract Templates"); string filePath = Path.Combine(_folder, FileOperations.RemoveWrongSymbols(fileName)); File.WriteAllText(filePath, content.ToString(), new UTF8Encoding(false)); await SaveOrganizationDifferenceImage(); return(filePath); }
public static List <ContractTemplate> QueryContractTemplate() { MySqlConnection con = DBTools.GetMySqlConnection(); MySqlCommand cmd; List <ContractTemplate> conTemps = new List <ContractTemplate>(); try { con.Open(); cmd = con.CreateCommand(); cmd.CommandText = QUERY_CONTRACT_TEMPLATE_STR; MySqlDataReader sqlRead = cmd.ExecuteReader(); cmd.Dispose(); while (sqlRead.Read()) { ContractTemplate conTemp = new ContractTemplate(); conTemp.TempId = int.Parse(sqlRead["id"].ToString()); conTemp.Name = sqlRead["name"].ToString(); conTemp.CreateDate = sqlRead["createdate"].ToString(); // // 5个栏目信息 // // conTemp.ColumnCount = 5; // List<String> columns = new List<String>(); // /* // columns.Add(sqlRead["column1"].ToString()); // columns.Add(sqlRead["column2"].ToString()); // columns.Add(sqlRead["column3"].ToString()); // columns.Add(sqlRead["column4"].ToString()); // columns.Add(sqlRead["column5"].ToString()); //*/ // for (int cnt = 1; cnt <= 5; cnt++) // { // String strColumn = "column" + cnt.ToString(); // columns.Add(sqlRead[strColumn].ToString()); // } // conTemp.ColumnNames = columns; // // 8个签字人信息 // // conTemp.SignCount = 8; // List<SignatureTemplate> signatures = new List<SignatureTemplate>(); // for (int cnt = 1; cnt <= 8; cnt++) // { // String strSignInfo = "signinfo" + cnt.ToString(); // String strSignId = "signId" + cnt.ToString(); // SignatureTemplate signDatas = new SignatureTemplate(); // signDatas.SignInfo = sqlRead[strSignInfo].ToString(); // signDatas.SignId = int.Parse(sqlRead[strSignId].ToString()); // signatures.Add(signDatas); // } // conTemp.SignDatas = signatures; conTemps.Add(conTemp); } con.Close(); con.Dispose(); } catch (Exception) { throw; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(conTemps); }