private ComponentData Validatepsedo(string logPath, List <ComponentCustomAction> caction) { var pseudo = Context.View.Components.Where(x => x.Type == ComponentType.pseudocore).FirstOrDefault(); if (pseudo != null) { ComponentData cd = new ComponentData(this.Context.ClientID, (Component)pseudo); cd.ImportFields = this.Context.ImportFields.Where(x => x.ComponentID == pseudo.ID).ToList(); cd.lookupPath = logPath + "/" + this.Context.ID + "_lookup.json"; // pseudo component base template modified template field due to privot so we cannot use template field from context template. that is why i init again to get template & field var currentTemplate = new CompExtention.ImportTemplate.Template(this.Context.Template.TemplateID, this.Context.ClientID, this.Context.Connection); cd.SetLookupList(dtLk); var action = caction.Where(x => x.ComponentName == pseudo.TableName).FirstOrDefault(); if (action != null) { cd.Validation = action.CustomAction; cd.Validation.Init(); } if (this.Context.Template.Type == CompExtention.ImportTemplate.Template.TemplateType.PIVOT) { List <string> com = new List <string>(); com.Add(pseudo.ID); var ViewAttributes = CompExtention.ComponentManager.GetComponentAttributes(string.Join(",", com.ToArray()), this.Context.ClientID, new CompExtention.DataAccess.ComponentDataHandler(this.Context.Connection)); cd.ExtractDataFromSource(dt); cd.LoadTargetPivotData(this.Context.Connection, currentTemplate.TemplateFields, ViewAttributes); cd.ValidatePivotData(false, this.Context.Connection, logPath, this.Context.ID, currentTemplate.TemplateFields, ViewAttributes); cd.Errors = cd.Errors.Where(x => x.Type == ErrorType.ERROR).ToList(); cd.Validation = null; cd.lookupPath = ""; cd.GetProcessedData(logPath, this.Context.ID); CacheData(logPath + "/" + "cd" + "_" + pseudo.ID + "_" + this.Context.ID + ".json", Newtonsoft.Json.JsonConvert.SerializeObject(cd)); return(cd); } else { cd.ExtractDataFromSource(dt); cd.LoadTargetData(this.Context.Connection); cd.ValidateData(this.Context.EnableUpdateDuplicate, this.Context.Connection, logPath, this.Context.ID); cd.Errors = cd.Errors.Where(x => x.Type == ErrorType.ERROR).ToList(); if (cd.Logs.Where(x => x.Type == ErrorType.ERROR).ToList().Count > 0 || cd.Errors.Where(x => x.Type == ErrorType.ERROR).ToList().Count > 0) { cd.IsValid = false; } cd.Validation = null; cd.lookupPath = ""; cd.GetProcessedData(logPath, this.Context.ID); CacheData(logPath + "/" + "cd" + "_" + pseudo.ID + "_" + this.Context.ID + ".json", Newtonsoft.Json.JsonConvert.SerializeObject(cd)); return(cd); } } else { return(null); } }
private void btnNew_Click(object sender, EventArgs e) { cmbType.Enabled = true; cmbViewList.Enabled = true; SelectedTemplate = null; txtCode.Text = ""; txtTemplateName.Text = ""; txtCategory.Text = ""; bindView(); BindCompType(); }
private void lstTemplate_SelectedIndexChanged(object sender, EventArgs e) { if (lstTemplate.SelectedItems.Count > 0) { CompExtention.ImportTemplate.Template imp = new CompExtention.ImportTemplate.Template(Connection, ClientID); SelectedTemplate = Templates[lstTemplate.SelectedIndices[0]]; cmbViewList.SelectedItem = null; cmbViewList.SelectedItem = Views.Where(x => x.ID == SelectedTemplate.ViewID).FirstOrDefault(); cmbType.Enabled = false; cmbViewList.Enabled = false; } }
public void UpdateChanges(string connection, int clientid) { ClientID = clientid; Connection = connection; ViewAttributes = new List <CompExtention.Attribute>(); SelectedView = new ComponentView(); Views = new List <ComponentView>(); SelectedTemplate = new CompExtention.ImportTemplate.Template(); Templates = new List <CompExtention.ImportTemplate.Template>(); Pivot = new PivotTemplate(); type = new Dictionary <int, string>(); type.Add(0, "Direct"); type.Add(1, "Pivot"); BindCompType(); bindTemplate(); bindView(); }
private void btnDelete_Click(object sender, EventArgs e) { if (SelectedTemplate != null) { CompExtention.ImportTemplate.Template tmp = new CompExtention.ImportTemplate.Template(SelectedTemplate.TemplateID, ClientID, Connection); if (MessageBox.Show("Are you sure,want to remove this template?", "Confirm Remove", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { if (tmp.Remove()) { MessageBox.Show("Template Removed"); bindTemplate(); btnNew_Click(null, null); } else { MessageBox.Show("Unable to remove template"); } } } else { MessageBox.Show("Choose one template from below list and then delete"); } }
private void btnSaveTemplate_Click(object sender, EventArgs e) { if (SelectedTemplate == null) { SelectedTemplate = new CompExtention.ImportTemplate.Template(); } CompExtention.ImportTemplate.Template tmp; if (SelectedTemplate.TemplateID != "") { tmp = new CompExtention.ImportTemplate.Template(SelectedTemplate.TemplateID, ClientID, Connection); } else { tmp = new CompExtention.ImportTemplate.Template(Connection, ClientID); } tmp.Name = txtTemplateName.Text; tmp.Code = txtCode.Text; tmp.Category = txtCategory.Text; tmp.ViewID = SelectedView.ID; if (((KeyValuePair <int, string>)cmbType.SelectedItem).Key == 0) { tmp.Type = CompExtention.ImportTemplate.Template.TemplateType.DIRECT; var Removed = new List <TemplateField>(); for (int x = 0; x < dgAttribute.Rows.Count; x++) { CompExtention.ImportTemplate.TemplateField te = new CompExtention.ImportTemplate.TemplateField(); if (dgAttribute.Rows[x].Cells[3].Value == null) { continue; } te.ID = dgAttribute.Rows[x].Cells[0].Value.ToString(); if (Convert.ToBoolean(dgAttribute.Rows[x].Cells["show"].Value) == true) { if (Convert.ToBoolean(dgAttribute.Rows[x].Cells["key"].Value)) { te.IsKey = true; } else { te.IsKey = false; } if (Convert.ToBoolean(dgAttribute.Rows[x].Cells["default"].Value)) { te.IsDefault = true; } else { te.IsDefault = false; } if (Convert.ToBoolean(dgAttribute.Rows[x].Cells["pivot"].Value)) { te.IsPivot = true; } else { te.IsPivot = false; } if (Convert.ToBoolean(dgAttribute.Rows[x].Cells["required"].Value)) { te.IsRequired = true; } else { te.IsRequired = false; } if (te.ID != "") { var tmap = tmp.TemplateFields.Where(xx => xx.ID == te.ID).FirstOrDefault(); if (tmap != null) { for (int i = 0; i < tmp.TemplateFields.Count; i++) { if (tmp.TemplateFields[i].ID == te.ID) { tmp.TemplateFields[i] = te; } } } else { tmp.TemplateFields.Add(te); } } } else { var tmap = tmp.TemplateFields.Where(xx => xx.ID == te.ID).FirstOrDefault(); if (tmap != null) { for (int i = 0; i < tmp.TemplateFields.Count; i++) { if (tmp.TemplateFields[i].ID == te.ID) { if (te.IsKey == false && te.IsDefault == false && te.IsRequired == false && te.IsPivot == false) { Removed.Add(te); } else { tmp.TemplateFields[i] = te; } } } } } } var temp = new List <TemplateField>(); foreach (TemplateField f in tmp.TemplateFields) { if (Removed.Where(x => x.ID == f.ID).FirstOrDefault() == null) { temp.Add(f); } } tmp.TemplateFields = temp; } else { tmp.Type = CompExtention.ImportTemplate.Template.TemplateType.PIVOT; if (Pivot != null) { var te = new CompExtention.ImportTemplate.TemplateField(); foreach (string s in Pivot.Rows) { te = new CompExtention.ImportTemplate.TemplateField(); te.ID = s; te.IsRow = true; te.IsRequired = true; te.IsKey = true; te.IsColumn = false; te.IsPivot = false; te.IsDefault = true; tmp.TemplateFields.Add(te); } te = new CompExtention.ImportTemplate.TemplateField(); te.ID = Pivot.Column; te.IsRow = false; te.IsColumn = true; te.IsPivot = false; te.IsRequired = true; te.IsKey = true; te.IsDefault = true; tmp.TemplateFields.Add(te); te = new CompExtention.ImportTemplate.TemplateField(); te.ID = Pivot.PivotColumn; te.IsRow = false; te.IsColumn = false; te.IsPivot = true; te.IsRequired = true; te.IsKey = true; te.IsDefault = true; tmp.TemplateFields.Add(te); } } if (tmp.Save()) { MessageBox.Show("Templated Created Successfully"); bindTemplate(); btnNew_Click(null, null); } else { MessageBox.Show("Error while save template"); } }
private void LoadImportTemplate() { Template = new CompExtention.ImportTemplate.Template(this.ImportTemplateID, ClientID, this.Connection); }