public void SetSelections(ReportItemDictionary <QVField> qvFieldCollection) { this._doc.Clear(); foreach (var item in qvFieldCollection.Values) { ObservableCollection <FieldValue> values; if (item.HasExpression) { values = this.GetValuesFromExpression(item); } else { values = item.Values; } var field = this._doc.Fields(item.Name); var value = field.GetNoValues(); int i = 0; foreach (var valueItem in values) { value.Add(); value[i].Text = valueItem.Value; value[i].Number = valueItem.Number; value[i].IsNumeric = valueItem.IsNumeric; i++; } field.SelectValues(value); } }
public ReportItemDictionary <QVField> GetCurrentSelection() { ReportItemDictionary <QVField> qc = new ReportItemDictionary <QVField>(); var selections = this._doc.GetCurrentSelections(); for (int i = 0; i < selections.Selections.Length; i++) { string fieldName = selections.VarId[i]; var field = this._doc.Fields(fieldName); QlikView.Common.QVField qvField = new QlikView.Common.QVField(); qvField.Name = field.Name(); var values = field.GetSelectedValues(); for (int j = 0; j < values.Count; j++) { qvField.Values.Add(new QlikView.Common.FieldValue() { Value = values[j].Text, IsNumeric = values[j].IsNumeric, Number = values[j].Number }); } qc.Add(qvField.Name, qvField); } return(qc); }
public override void Save() { //Save task to main config this._xmlDoc = new XmlDocument(); this._xmlDoc.Load(ReportConfig.ConfigLocations["ReportConfig"]); XmlNode rootNode = this.GetItemRootNode(); //Clear all the children nodes rootNode.RemoveAll(); this.RecreateItemXmlNodesForMainConfig(rootNode); this._xmlDoc.Save(ReportConfig.ConfigLocations["ReportConfig"]); foreach (var item in ReportConfig.ConfigLocations.Keys) { if (item != "ReportConfig") { this._xmlDoc = new XmlDocument(); this._xmlDoc.Load(ReportConfig.ConfigLocations[item]); XmlNode rootNode1 = this.GetItemRootNode(); //Clear all the children nodes rootNode1.RemoveAll(); var itemCollection = new ReportItemDictionary <ReportTask>(); itemCollection.Add(item, this.ItemCollection[item]); this.RecreateItemXmlNodes(rootNode1, itemCollection); this._xmlDoc.Save(ReportConfig.ConfigLocations[item]); } } }
protected override void RecreateItemXmlNodes(XmlNode itemRootNode, ReportItemDictionary <Recipient> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Recipient", item.Name, item.Description); node.AddChildNode("Email", item.Email); node.AddChildNode("EmailCC", item.EmailCC ?? string.Empty); itemRootNode.AppendChild(node); } }
private void SetVariables(ReportItemDictionary <QvVariable> qvVaiableCollection) { foreach (var item in qvVaiableCollection.Values) { Variable v = this._doc.Variables(item.Name); if (v != null) { v.SetContent(this.GetValueFromExpression(item), false); } } }
protected override void RecreateItemXmlNodes(XmlNode itemRootNode, ReportItemDictionary <RecipientGroup> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("RecipientGroup", item.Name, item.Description); foreach (var recipient in item.RecipientList.Values) { node.AddChildNode("Recipient", recipient.Name); } itemRootNode.AppendChild(node); } }
protected override void RecreateItemXmlNodes(XmlNode itemRootNode, ReportItemDictionary <ReportSchedulerDefinition> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Scheduler", item.Name, item.Description); XmlNode tasksNode = node.AddChildNode("Tasks", string.Empty); foreach (var task in item.Tasks.Values) { tasksNode.AddChildNode("Task", task.Name); } itemRootNode.AppendChild(node); } }
protected override void RecreateItemXmlNodes(XmlNode itemRootNode, ReportItemDictionary <QlikViewReport> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Report", item.Name, item.Description); node.AddChildNode("Connection", item.Connection.Name); node.AddChildNode("OutputFileName", item.OutputFielName); node.AddChildNode("EnableDynamicNaming", item.EnableDynamicNaming.ToString()); node.AddChildNode("EmbeddedInMail", item.IsEmbeddedInMail.ToString()); node.AddChildNode("QlikViewExportObjectId", item.QlikViewExportObjectId); node.AddChildNode("Filter", item.Filter == null ? string.Empty : item.Filter.Name); node.AddChildNode("ReportType", ((int)item.ReportType).ToString()); itemRootNode.AppendChild(node); } }
public override void Save() { foreach (var item in ReportConfig.ConfigLocations.Keys) { this._xmlDoc = new XmlDocument(); this._xmlDoc.Load(ReportConfig.ConfigLocations[item]); XmlNode rootNode = this.GetItemRootNode(); //Clear all the children nodes rootNode.RemoveAll(); ReportItemDictionary <QlikViewReport> itemCollection = this.GetReportsByTask(item); this.RecreateItemXmlNodes(rootNode, itemCollection); this._xmlDoc.Save(ReportConfig.ConfigLocations[item]); } }
public void Run(string task) { ReportItemDictionary <ReportTask> tasks = ReportConfig.ReportTaskManager.ItemCollection; ExportEngine engine = new ExportEngine(new QlikViewConnector()); engine.Logger = this.Logger; ReportTask taskItem = tasks.Values.FirstOrDefault(x => x.Name.ToString() == task); if (taskItem != null) { Console.WriteLine("Running task first time: " + taskItem.Name + "......."); engine.Logger.Message("Running task first time: " + taskItem.Name + "......."); IError error = engine.RunTask(taskItem, ReportConfig.SmtpServerManager.SmtpServer); if (error.HasError == false) { Console.WriteLine("Running task fisrt time" + taskItem.Name + " complete......."); engine.Logger.Message("Running task fisrt time" + taskItem.Name + " complete......."); } else { Console.WriteLine("Running task fisrt time " + taskItem.Name + " failed......."); engine.Logger.Error("Running task fisrt time " + taskItem.Name + " failed....... \n" + error.ErrorMessage.ToString()); //MailHelper.ExceptionNotify("Running task fisrt time " + taskItem.Name + " failed", error.ErrorMessage.ToString(), ReportConfig.Instance.SmtpServer); Console.WriteLine("Running task second time: " + taskItem.Name + "......."); engine.Logger.Message("Running task second time: " + taskItem.Name + "......."); error = engine.RunTask(taskItem, ReportConfig.SmtpServerManager.SmtpServer); if (error.HasError) { MailHelper.ExceptionNotify("Running task second time " + taskItem.Name + " failed", error.ErrorMessage.ToString(), ReportConfig.SmtpServerManager.SmtpServer); } } } else { engine.Logger.Error(string.Format("There is no task {0}. ", task)); } this.Close(); }
private ReportItemDictionary <QlikViewReport> GetReportsByTask(string task) { ReportItemDictionary <QlikViewReport> itemCollection = new ReportItemDictionary <QlikViewReport>(); foreach (var item in this.ItemCollection) { if (item.Value.Parents.ContainsKey(task)) { itemCollection.Add(item); } else if (item.Value.Parents.Count == 0 && task == "ReportConfig") { itemCollection.Add(item); } } return(itemCollection); }
private ReportItemDictionary <Filter> GetFiltersByTask(string task) { ReportItemDictionary <Filter> itemCollection = new ReportItemDictionary <Filter>(); foreach (var item in this.ItemCollection) { if (item.Value.Parents.Count > 0 && item.Value.Parents.Where(x => x.Value.Parents.ContainsKey(task)).Count() > 0) { itemCollection.Add(item); } //if the filter has no parents or all the parents have no perants, save to the main config else if ((item.Value.Parents.Count == 0 || (item.Value.Parents.Count > 0 && item.Value.Parents.Where(x => x.Value.Parents.Count > 0).Count() == 0)) && task == "ReportConfig") { itemCollection.Add(item); } } return(itemCollection); }
private void btnFilterPreview_Click(object sender, EventArgs e) { if (this.CurrentConnection == null) { MessageBox.Show("Please select the connection."); return; } FilterSelectionForm form = new FilterSelectionForm(); form.Connection = this.CurrentConnection; form.Fields = this.FieldCollection; DialogResult result = form.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.FieldCollection = form.Fields; this.RefreshFieldDataGrid(); } }
private void SetVariables(ReportItemDictionary<QvVariable> qvVaiableCollection) { foreach (var item in qvVaiableCollection.Values) { Variable v = this._doc.Variables(item.Name); if (v != null) { v.SetContent(this.GetValueFromExpression(item),false); } } }
public ReportItemBase() { this.Parents = new ReportItemDictionary <IReportItem>(); }
protected override void RecreateItemXmlNodes(System.Xml.XmlNode itemRootNode, ReportItemDictionary <ReportTask> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Task", item.Name, item.Description); node.AddChildNode("OutputFolder", item.OutputFolder); node.AddChildNode("SendInSingleMail", item.IsSendMailInSingleMail.ToString()); node.AddChildNode("MergeInSingleExcel", item.IsMergeInSingleExcel.ToString()); XmlNode reportsNode = node.AddChildNode("Reports", string.Empty); foreach (var report in item.Reports.Values) { reportsNode.AddChildNode("Report", report.Name); } XmlNode recipientsNode = node.AddChildNode("Recipients", string.Empty); foreach (var recipient in item.Recipients.Values) { recipientsNode.AddChildNode("Recipient", recipient.Name); } node.AddChildNode("RecipientGroup", item.Group == null ? string.Empty : item.Group.Name); XmlNode messageNode = node.AddChildNode("Message", string.Empty); messageNode.AddChildNode("From", item.MessageDefinition.From); messageNode.AddChildNode("CC", item.MessageDefinition.CC ?? string.Empty); messageNode.AddChildNode("BCC", item.MessageDefinition.BCC ?? string.Empty); messageNode.AddChildNode("Subject", item.MessageDefinition.Subject ?? string.Empty); XmlNode bodyNode = messageNode.AddChildNode("Body", string.Empty); XmlCDataSection dateSec = this._xmlDoc.CreateCDataSection(item.MessageDefinition.Body); bodyNode.AppendChild(dateSec); if (item.FtpServer != null) { XmlNode ftpServerNode = node.AddChildNode("FtpServer", string.Empty); ftpServerNode.AddChildNode("Host", item.FtpServer.Host); ftpServerNode.AddChildNode("Username", item.FtpServer.Username); ftpServerNode.AddChildNode("Password", EncryptionDecryption.Encode(item.FtpServer.Password)); ftpServerNode.AddChildNode("Folder", item.FtpServer.Folder); ftpServerNode.AddChildNode("Port", item.FtpServer.Port); } itemRootNode.AppendChild(node); } }
protected override void RecreateItemXmlNodes(System.Xml.XmlNode itemRootNode, ReportItemDictionary <ReportConnection> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Connection", item.Name, item.Description); node.AddChildNode("IsLocal", item.IsLocal.ToString()); node.AddChildNode("ServerName", item.ServerName); node.AddChildNode("WebServicePort", item.ServicePort); node.AddChildNode("WebServiceHost", item.ServiceHost); node.AddChildNode("QlikViewDocument", item.QlikViewDocument); node.AddChildNode("User", item.User); node.AddChildNode("Password", EncryptionDecryption.Encode(item.Password)); itemRootNode.AppendChild(node); } }
public RecipientGroup() { this.RecipientList = new ReportItemDictionary <Recipient>(); }
public ReportItemDictionary<QVField> GetCurrentSelection() { ReportItemDictionary<QVField> qc = new ReportItemDictionary<QVField>(); var selections = this._doc.GetCurrentSelections(); for (int i = 0; i < selections.Selections.Length; i++) { string fieldName = selections.VarId[i]; var field = this._doc.Fields(fieldName); QlikView.Common.QVField qvField = new QlikView.Common.QVField(); qvField.Name = field.Name(); var values = field.GetSelectedValues(); for (int j = 0; j < values.Count; j++) { qvField.Values.Add(new QlikView.Common.FieldValue() { Value = values[j].Text, IsNumeric = values[j].IsNumeric, Number = values[j].Number }); } qc.Add(qvField.Name, qvField); } return qc; }
private void btnConfirm_Click(object sender, EventArgs e) { this.Fields = this._qlikViewConnector.GetCurrentSelection(); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
public ReportSchedulerDefinition() { this.Tasks = new ReportItemDictionary <ReportTask>(); }
protected override void RecreateItemXmlNodes(System.Xml.XmlNode itemRootNode, ReportItemDictionary <Filter> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Filter", item.Name, item.Description); node.AddChildNode("Connection", item.Connection.Name); node.AddChildNode("Fields", string.Empty); foreach (var fieldItem in item.Fields.Values) { XmlNode fieldNode = this.CreateNodeBase("Field", fieldItem.Name, string.Empty); fieldNode.Attributes.Append(_xmlDoc.CreateAttribute("Expression")); fieldNode.Attributes["Expression"].Value = fieldItem.Expression ?? string.Empty; foreach (var valueItem in fieldItem.Values) { XmlNode valueNode = fieldNode.AddChildNode("Value", valueItem.Value); XmlAttribute numberAttr = valueNode.OwnerDocument.CreateAttribute("Number"); numberAttr.Value = valueItem.Number.ToString(); valueNode.Attributes.Append(numberAttr); XmlAttribute isNumericAttr = valueNode.OwnerDocument.CreateAttribute("IsNumeric"); isNumericAttr.Value = valueItem.IsNumeric.ToString(); valueNode.Attributes.Append(isNumericAttr); } node.ChildNodes[1].AppendChild(fieldNode); } node.AddChildNode("Variables", string.Empty); foreach (var variableItem in item.Variables.Values) { XmlNode variableNode = node.ChildNodes[2].AddChildNode("Variable", variableItem.Value); variableNode.Attributes.Append(_xmlDoc.CreateAttribute("Name")); variableNode.Attributes["Name"].Value = variableItem.Name; variableNode.Attributes.Append(_xmlDoc.CreateAttribute("Expression")); variableNode.Attributes["Expression"].Value = variableItem.Expression ?? string.Empty; } itemRootNode.AppendChild(node); } }
public void SetSelections(ReportItemDictionary<QVField> qvFieldCollection) { this._doc.Clear(); foreach (var item in qvFieldCollection.Values) { ObservableCollection<FieldValue> values; if (item.HasExpression) { values = this.GetValuesFromExpression(item); } else { values = item.Values; } var field = this._doc.Fields(item.Name); var value = field.GetNoValues(); int i = 0; foreach (var valueItem in values) { value.Add(); value[i].Text = valueItem.Value; value[i].Number = valueItem.Number; value[i].IsNumeric = valueItem.IsNumeric; i++; } field.SelectValues(value); } }
protected abstract void RecreateItemXmlNodes(XmlNode itemRootNode, ReportItemDictionary <T> itemCollection);
public Filter() { this.Fields = new ReportItemDictionary <QVField>(); this.Variables = new ReportItemDictionary <QvVariable>(); }