Example #1
0
        public async Task ManageLists(ListConfig listConfig, HostConfig hostConfig)
        {
            Dictionary <string, List <string> > lists = await fetchList(listConfig);

            ListConfigRepository[listConfig.Name] = listConfig;


            handleSaveFetchedLists(listConfig, lists);

            Executor.Connector.Feedback.ErrorAdded  += errorOutputHandler;
            Executor.Connector.Feedback.OutputAdded += outputOutputHandler;

            Executor.Feedback.ErrorAdded  += errorOutputHandler;
            Executor.Feedback.OutputAdded += outputOutputHandler;

            Executor.HostConfig = hostConfig;
            Executor.ListConfig = listConfig;

            bool actionResult = Executor.DoPreActions();


            foreach (string name in lists.Keys.Where(i => i != Util.MAINLISTNAME))
            {
                Console.WriteLine($"Processing {name}...");
                Executor.ProcessList(name, lists[name]);
            }
        }
Example #2
0
        public JsonResult GetColumnFromSQL()
        {
            string     id   = QueryString("listId");
            ListConfig list = UnitOfWork.GetByKey <ListConfig>(id);

            list.CheckNotNull("ListConfig");
            string connName = WebConfigHelper.GetConnSettingNameByDBName(list.DBName);

            if (!string.IsNullOrEmpty(list.TableName) && !string.IsNullOrEmpty(connName))
            {
                string    sql       = string.Format("select top 1 * FROM {0}", list.TableName);
                SqlHelper sqlHelper = new SqlHelper(connName);
                var       dt        = sqlHelper.ExcuteTable(sql);

                List <string> colNames = new List <string>();
                foreach (DataColumn dc in dt.Columns)
                {
                    colNames.Add(dc.ColumnName);
                }

                if (colNames.Count() > 0)
                {
                    return(Json(colNames));
                }
            }

            return(Json(false));
        }
Example #3
0
        public async Task ManageLists(string listConfigName, string hostConfigName, bool interactive = true)
        {
            ListConfig listConfig = handleGetListConfig(listConfigName, interactive);

            if (listConfig == null)
            {
                throw new NoNullAllowedException("Got null for a ListConfig...")
                      {
                      };
            }

            HostConfig hostConfig = handleGetHostConfig(hostConfigName, interactive);

            if (hostConfig == null)
            {
                throw new NoNullAllowedException("Got null for a HostConfig...")
                      {
                      };
            }

            if (interactive)
            {
                Console.WriteLine($"Got Listconfig as {listConfig}\nGot Hostconfig as {hostConfig}\n.");
                if (!ConsoleHelper.ReadInputAsBool("Proceed with fetch (y/n)", "y"))
                {
                    return;
                }
            }

            ManageLists(listConfig, hostConfig);
        }
Example #4
0
        private async Task <Dictionary <string, List <string> > > fetchList(ListConfig listConfig)
        {
            if (ListFetcher == null)
            {
                ListFetcher = new ListFetcher(listConfig);
            }
            else
            {
                ListFetcher.ListConfig = listConfig;
            }

            ListFetcher.Feedback.ErrorAdded  += errorOutputHandler;
            ListFetcher.Feedback.OutputAdded += outputOutputHandler;

//            string saveFile = Environment.GetEnvironmentVariable("HOME") + "/test/emerging_threats.txt";

            Console.WriteLine($"Trying to fetch list from {listConfig.Name} ({listConfig.Url})...");

            Console.WriteLine("Fetching list.");
            Task fetchTask = Task.Run(ListFetcher.FetchAndParse);

            while (!fetchTask.IsCompleted)
            {
                Console.Write(".");
                Thread.Sleep(500);
            }

            Console.WriteLine("Done fetching list.");

            return(ListFetcher.Lists);
        }
Example #5
0
        /// <summary>
        /// 获取列表页配置
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        private ListConfig LoadListConfig(XmlNode xmlNode)
        {
            if (xmlNode == null)
            {
                return(null);
            }
            ListConfig config = new ListConfig();

            #region ConfigBase 开始
            config.Url        = xmlNode.SelectSingleNode("Url").InnerText;
            config.Encoding   = Encoding.GetEncoding(xmlNode.SelectSingleNode("Encoding").InnerText);
            config.MethodType = xmlNode.SelectSingleNode("Encoding").InnerText == "POST" ? MethodType.POST : MethodType.GET;
            string subPageConfig = xmlNode.SelectSingleNode("SubPageConfig").InnerText;
            string plugNameSpace = xmlNode.SelectSingleNode("Plug").InnerText;
            if (!string.IsNullOrWhiteSpace(plugNameSpace))
            {
                config.Plug = CreatePlug(plugNameSpace);
            }
            if (!string.IsNullOrWhiteSpace(subPageConfig))
            {
                config.SubConfig = LoadPageConfig(subPageConfig);
            }
            #endregion

            #region ListConfig 开始
            config.UrlItem              = CreateUrlItem(xmlNode.SelectSingleNode("UrlItem"));
            config.StartIndex           = int.Parse(xmlNode.SelectSingleNode("StartIndex").InnerText);
            config.Increment            = int.Parse(xmlNode.SelectSingleNode("Increment").InnerText);
            config.MaxPage              = int.Parse(xmlNode.SelectSingleNode("MaxPage").InnerText);
            config.PageCountSnifferItem = CreateSnifferItem(xmlNode.SelectSingleNode("PageCountSnifferItem"));
            #endregion
            return(config);
        }
Example #6
0
        public void ManageList_ListConfig_HostConfig_test()
        {
            const string LISTCONFIGNAME = "testlist";
            const string HOSTCONFIGNAME = "testhost";

            ListConfig listConfigDummy = TestHelper.CreateDummyListConfig(LISTCONFIGNAME);
            HostConfig hostConfigDummy = TestHelper.CreateDummyHostConfig(HOSTCONFIGNAME);

            NFTManager nftManager = createTestSubject();

            Dictionary <string, List <string> > listsDummy = new Dictionary <string, List <string> >();

            listsDummy["TEST01"] = new List <string>(new string[] { "TEST_ELEM_01" });

            nftManager.Executor.DoPreActions().Returns(true);
            nftManager.Executor.ProcessList("TEST01", listsDummy["TEST01"]).Returns(true);

            nftManager.ListConfigRepository.Get(LISTCONFIGNAME).Returns(listConfigDummy);
            nftManager.HostConfigRepository.Get(HOSTCONFIGNAME).Returns(hostConfigDummy);

            nftManager.ListFetcher.Lists = listsDummy;
            nftManager.ListFetcher.FetchAndParse().Returns(Task.CompletedTask);

            nftManager.ManageLists(listConfigDummy, hostConfigDummy);

            // TODO: asserts that required calls have been made.
            Assert.True(true);
        }
Example #7
0
        public JsonResult GetButtonList()
        {
            string     id = QueryString("listId");
            ListConfig fc = UnitOfWork.GetByKey <ListConfig>(id);

            fc.CheckNotNull("ListConfig");
            return(Json(fc.GetButtonList()));
        }
Example #8
0
        public ActionResult ButtonDetail()
        {
            string     id = QueryString("Id");
            ListConfig fc = UnitOfWork.GetByKey <ListConfig>(id);

            fc.CheckNotNull("ListConfig");
            ViewBag.FunctionList = fc.GetScriptFunctionList().Select(a => new { text = a, value = a }).ToJson();
            return(View());
        }
Example #9
0
 internal ListSetup(ListConfig list, CollectionSetup collection)
 {
     PageSize                     = list.PageSize;
     SearchBarVisible             = list.SearchBarVisible;
     ReorderingAllowed            = list.ReorderingAllowed;
     ListType                     = list.ListEditorType;
     EmptyVariantColumnVisibility = list.EmptyVariantColumnVisibility;
     Buttons = list.Buttons.ToList(button => new ButtonSetup(button, collection.EntityVariant, collection.SubEntityVariants));
     Panes   = list.Panes.ToList(pane => new PaneSetup(pane));
 }
Example #10
0
        public JsonResult Get()
        {
            string id = QueryString("id");

            id.CheckNotNullOrEmpty("id");
            ListConfig cList = UnitOfWork.GetByKey <ListConfig>(id);

            cList.CheckNotNull("cList");
            return(Json(cList));
        }
        public void SerializeTest()
        {
            // TODO: asserts ...
            ListConfig listConfig = TestHelper.CreateDummyListConfig("test");

            IRepository <ListConfig> tested = new Repository <ListConfig>();

            tested[listConfig.Name] = listConfig;

            Assert.True(true);
        }
Example #12
0
 public static List ToList(this ListConfig list, Collection collection)
 {
     return(new List
     {
         PageSize = list.PageSize,
         SearchBarVisible = list.SearchBarVisible,
         ListType = list.ListEditorType,
         EmptyVariantColumnVisibility = list.EmptyVariantColumnVisibility,
         Buttons = list.Buttons.ToList(button => button.ToButton(collection.SubEntityVariants, collection.EntityVariant)),
         Panes = list.Panes.ToList(pane => pane.ToPane())
     });
 }
        public void DeserializeTest()
        {
            string     expectedName = "test";
            ListConfig expected     = TestHelper.CreateDummyListConfig(expectedName);

            IRepository <ListConfig> tested = new Repository <ListConfig>();
            ListConfig actual = (ListConfig)tested[expectedName];

            // TODO: Equals implementation for complex types...

            Assert.Equal(expected, actual);
        }
Example #14
0
        public JsonResult SaveButton(string listId)
        {
            var        dicList = QueryString("rows").JsonToDictionaryList();
            ListConfig fc      = UnitOfWork.GetByKey <ListConfig>(listId);

            fc.CheckNotNull("ListConfig");
            fc.UpdateButton(dicList);
            UnitOfWork.UpdateEntity(fc);
            bool res = UnitOfWork.Commit();

            return(Json(res));
        }
Example #15
0
        private ListConfig handleGetListConfig(string listName = null, bool interactive = false)
        {
            if (!interactive)
            {
                if (string.IsNullOrEmpty(listName))
                {
                    return(null);
                }
                return(ListConfigRepository.Get(listName));
            }
            else
            {
                ListConfig foundList    = null;
                bool       newlyCreated = false;
                Console.WriteLine("List config retrieval / creation...");

                string whileMsg;
                do
                {
                    if (ConsoleHelper.ReadInputAsBool("Create new (y/n)", "n"))
                    {
                        foundList    = (ListConfig)ListConfigRepository.Creator.Create(listName);
                        whileMsg     = $"Created list with name {foundList?.Name}. Correct (y/n)";
                        newlyCreated = true;
                    }
                    else
                    {
                        listName  = ConsoleHelper.ReadInput("list name", listName);
                        foundList = (ListConfig)ListConfigRepository.Get(listName);
                        if (foundList == null)
                        {
                            whileMsg = $"No list found by the name of {listName}. Exit (y/n)?";
                        }
                        else
                        {
                            whileMsg     = $"Found list with name {foundList.Name}. Correct(y/n)";
                            newlyCreated = false;
                        }
                    }
                }while (!ConsoleHelper.ReadInputAsBool(whileMsg, "y"));

                if (newlyCreated && ConsoleHelper.ReadInputAsBool("Serialize list config (y/n)", "y"))
                {
                    ListConfigRepository[foundList.Name] = foundList;
                }

                return(foundList);
            }
        }
Example #16
0
        private void handleSaveFetchedLists(ListConfig listConfig, Dictionary <string, List <string> > lists)
        {
            foreach (KeyValuePair <string, List <string> > kvp in lists)
            {
                ContentList cl = new ContentList()
                {
                    Name      = kvp.Key,
                    Version   = listConfig.Version,
                    IsSubList = (kvp.Key != Util.MAINLISTNAME),
                    Elements  = kvp.Value,
                };


                ListRepository.Set(cl);
            }
        }
Example #17
0
        public void ManageLists_WhenNotInteractive()
        {
            const string LISTCONFIGNAME = "testlist";
            const string HOSTCONFIGNAME = "testhost";

            ListConfig listConfigDummy = TestHelper.CreateDummyListConfig(LISTCONFIGNAME);
            HostConfig hostConfigDummy = TestHelper.CreateDummyHostConfig(HOSTCONFIGNAME);

            NFTManager nftManager = createTestSubject();

            nftManager.HostConfigRepository.Get(Arg.Any <string>()).Returns(hostConfigDummy);
            nftManager.ListConfigRepository.Get(Arg.Any <string>()).Returns(listConfigDummy);


            Assert.True(true);
        }
Example #18
0
        private bool checkUpdateAvailable(ListConfig listConfig)
        {
            bool retVal = false;

            // If not revisioned always return true -->
            if (listConfig.IsRevisioned == false)
            {
                retVal = true;
            }
            else
            {
                string currVer = listConfig.Version;
//                string availVer = ListFetcher.Get
                //TODO: implement version checking
            }

            return(retVal);
        }
Example #19
0
        /// <summary>
        /// TODO: make configurable.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ListConfig CreateDummyListConfig(string name = null)
        {
            ListConfig listConfig = new ListConfig()
            {
                Name                   = name ?? "test",
                Description            = (name ?? "test") + "description",
                Url                    = new Uri("http://localhost"),
                IsComposite            = true,
                IsRevisioned           = true,
                RevisionRegex          = new Regex(".*"),
                SubsetHeader           = new Regex(".*"),
                EmptyLineIndicators    = new Regex(".*"),
                InvalidListnameChars   = new Regex("#"),
                InvalidCharReplacement = "#",
                LineSeparator          = Environment.NewLine,
            };

            return(listConfig);
        }
Example #20
0
        private DataGrid GetDataGrid(ListConfig list)
        {
            var propertyDic = list.PropertySetting.JsonToDictionary();
            var style       = new Dictionary <string, object>();
            var dataOptions = new Dictionary <string, object>();

            EasyUICtrlPrepareData pData = new EasyUICtrlPrepareData()
            {
                Style       = style,
                DataOptions = dataOptions,
                Attr        = propertyDic
            };

            List <Dictionary <string, object> > collist = list.ColumnSetting.JsonToDictionaryList();
            DataGrid dg = new DataGrid("mf_grid", pData, collist);

            dg.Prepare();
            return(dg);
        }
Example #21
0
        public JsonResult Save()
        {
            var dic = Request.Form["formData"].JsonToObject <Dictionary <string, object> >();

            if (string.IsNullOrEmpty(dic.GetValue("Id")))
            {
                ListConfig cList = ConvertHelper.ConvertToObj <ListConfig>(dic);
                cList.Id              = GuidHelper.CreateTimeOrderID();
                cList.ButtonSetting   = DefaultValue.GetListButtonJson();
                cList.PropertySetting = DefaultValue.GetListPropertyJson();
                UnitOfWork.Add(cList);
            }
            else
            {
                ListConfig cList = UnitOfWork.GetByKey <ListConfig>(dic.GetValue("Id"));
                ConvertHelper.UpdateEntity(cList, dic);
                UnitOfWork.UpdateEntity(cList);
            }

            bool b = UnitOfWork.Commit();

            return(Json(b));
        }
Example #22
0
     internal void Upgrade()
     {
         if (Config_Version < 20200604)
         {
             if (Grafts != null)
             {
                 Augments = Grafts;
             }
         }
         if (Config_Version < 20201102)
         {
             Config_Version = 20201102;
             ZyMod.Api("config save", this);
         }
         if (Skills == null)
         {
             Skills = new ListConfig {
                 Enabled = false
             }
         }
         ;
         if (Augments == null)
         {
             Augments = new ListConfig {
                 Enabled = false
             }
         }
         ;
         if (Equipments == null)
         {
             Equipments = new ListConfig {
                 Enabled = false
             }
         }
         ;
     }
 }
Example #23
0
        private List <Button> GetButtonList(ListConfig list)
        {
            List <Button> buttonList    = new List <Button>();
            var           buttonDicList = list.GetButtonList();

            foreach (var buttonDic in buttonDicList)
            {
                var detailDic = buttonDic.GetValue("Detail").JsonToDictionary();
                var attr      = new Dictionary <string, object>();

                string title = buttonDic.GetValue("title");
                buttonDic.Remove("title");
                if (!string.IsNullOrEmpty(detailDic.GetValue("onclick")))
                {
                    if (!string.IsNullOrEmpty(detailDic.GetValue("mustSelect")))
                    {
                        string action = string.Format("checkSelection(\"{0}\",\"{1}\")", detailDic.GetValue("mustSelect"), detailDic.GetValue("onclick"));
                        buttonDic.SetValue("onclick", action);
                    }
                    else
                    {
                        buttonDic.SetValue("onclick", detailDic.GetValue("onclick"));
                    }
                }
                else if (!string.IsNullOrEmpty(buttonDic.GetValue("url")))
                {
                    string url = buttonDic.GetValue("url");
                    //高宽
                    string width  = detailDic.GetValue("width");
                    string height = detailDic.GetValue("height");

                    if (!string.IsNullOrEmpty(detailDic.GetValue("mustSelect")))
                    {
                        string clickCmd = "\"openWindowWithUrl(\\\"" + url + "\\\",\\\"" + width + "\\\",\\\"" + height + "\\\")\"";
                        string action   = string.Format("checkSelection(\"{0}\",{1})", detailDic.GetValue("mustSelect"), clickCmd);
                        buttonDic.SetValue("onclick", action);
                    }
                    else
                    {
                        string clickCmd = "openWindowWithUrl(\"" + url + "\")";
                        buttonDic.SetValue("onclick", clickCmd);
                    }
                    buttonDic.Remove("url");
                }

                var classNames = new List <string>();
                if (buttonDic.GetValue("hidden").ToLower() == "true")
                {
                    classNames.Add("euiCtrlHidden");
                }

                EasyUICtrlPrepareData pData = new EasyUICtrlPrepareData()
                {
                    Attr       = buttonDic,
                    ClassNames = classNames
                };
                Button dg = new Button(buttonDic.GetValue("id"), pData, title);
                dg.Prepare();
                buttonList.Add(dg);
            }

            return(buttonList);
        }
Example #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="listConfig"></param>
        /// <param name="dte"></param>
        /// <param name="dtagrid"></param>

        public List<String> getListData(ListConfig listConfig, DateTime dte, DataGridView dtagrid, String EmailMgetFileName, Boolean sendTestEmails)
        {

            SP.List oList = _context.Web.Lists.GetByTitle(listConfig._SharePointSListName);
            List<String> sentRecipients = new List<string>();
            CamlQuery camlQuery = new CamlQuery();
            Boolean canceled = false;
            if (dtagrid != null)
            {// get all all data for testing
                camlQuery.ViewXml = "<View><Query><Where><Geq>" +
                    "<FieldRef Name='ID'/>" +
                    "<Value Type='Number'>0</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
            }
            else
            {

                camlQuery.ViewXml = "<View><Query><Where><And>";
                foreach (String af in listConfig._ActiveFields)
                    camlQuery.ViewXml += "<Eq><FieldRef Name='" + af + "'/><Value Type='Bool'>True</Value></Eq>";
                camlQuery.ViewXml += "</And></Where></Query></View>";

            }
            if (listConfig._CAMLQUery != null && !listConfig._CAMLQUery.Equals(""))// over ride the query if user types it.
                camlQuery.ViewXml = "<View><Query><Where>" + listConfig._CAMLQUery + "</Where></Query></View>";


            ListItemCollection collListItem = oList.GetItems(camlQuery);
            try
            {
                _context.Load(collListItem);
            }
            catch (Exception ex)
            {
                String Msg = @"[CAML Query " + camlQuery.ViewXml + " Failed:" + ex.Message + "]";
                if (dtagrid != null)
                    MessageBox.Show(ex.Message, "Error in CAML");
                else
                    throw new Exception(Msg, ex);
            }

            int activeFieldsCount = 0;
       //     if (dtagrid != null)
       //     {
                activeFieldsCount = setUpDataGrid(listConfig, dtagrid);

       //     }

            List siteAppList = _context.Web.Lists.GetByTitle(listConfig._SharePointSListName);
            // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll" 
            // so that it grabs all list items, regardless of the folder they are in. 
            try
            {
                _context.ExecuteQuery();
            }
            catch (Exception ex)
            {
                String Msg = @"[CAML Query " + camlQuery.ViewXml + " Failed:" + ex.Message + "]";
                if (dtagrid != null)
                    MessageBox.Show(ex.Message, "Error in CAML");
                else
                    throw new Exception(Msg, ex);
            }


            int Frequency = 7;
            String FrequencyDBValue = "";
            String[] activeFlags = new string[activeFieldsCount];
            Object[] objRow = new Object[activeFieldsCount];
            int emailDiagCount = 0;
            foreach (ListItem listItem in collListItem)
            {
                Dictionary<String, String> secondaryValues = getSecondaryListData(listConfig._secondaryListName, listItem[listConfig._joinFeeld]);
                //             Dictionary<String, String> secondaryValues = getSecondaryListData("Requests", listItem["RequestID"]);

                String emailAddress = "unknown";
                String emailName = "unknown";
                Object obj = listItem[listConfig._UserField];


                // go thru and figure out if the data is null.. then we have to either  default things and run..
                // or bail... architecureal decision
                if (listItem[listConfig._UserField] == null || listItem[listConfig._UserField].ToString().Length < 1)
                    continue;// no data to process
                int activeCount = 0;
                foreach (String af in listConfig._ActiveFields)
                {
                    if (listItem[af] == null)
                        activeFlags[activeCount++] = "False";
                    else
                        activeFlags[activeCount++] = listItem[af].ToString();
                }
                foreach (String af in listConfig._secondaryFields)
                {
                    activeFlags[activeCount++] = secondaryValues[af].ToString();
                }

                if (listItem[listConfig._FrequencyField] == null)
                    Frequency = 7;
                else
                {
                    try
                    {
                        SPFieldMultiChoiceValue choices = new SPFieldMultiChoiceValue(listItem[listConfig._FrequencyField].ToString());
                        if (choices.Count >= 1)
                        {
                            Frequency = Int32.Parse(listConfig._FrequecncyItems[choices[0]]);
                        }
                        FrequencyDBValue = choices[0];
                    }
                    catch (Exception ex)
                    {
                        Frequency = 7;
                    }
                }

                String dteField = listConfig._DateField;// "Created";


                if (listItem[listConfig._UserField] != null && listItem[listConfig._UserField].ToString().Length > 0)
                {
                    FieldUserValue UserName = (FieldUserValue)listItem[listConfig._UserField];
                    emailName = UserName.LookupValue;
                    emailAddress = getUserEmail(UserName);
                }
                String send = "Yes";
                Int32 interval = -1;


                if (dteField != null && listItem[dteField] != null)
                    interval = (DateTime.Parse(dte.ToString("d")) - DateTime.Parse(DateTime.Parse(listItem[dteField].ToString()).ToString("d"))).Days;// add one to make it inclusive of the day it ran on.
                else
                {
                    String Msg = @"[Date field  is NULL]";
                    if (dtagrid != null)
                        MessageBox.Show(Msg, "Error in Processing interval");
                    else
                        throw new Exception(Msg);
                }
                if (interval <= 0 || (interval % Frequency) != 0)
                    send = "No";

                int gridRowCount = 0;

                for (gridRowCount = 0; gridRowCount < activeCount; gridRowCount++)
                {
                    if (activeFlags[gridRowCount] == "False")
                        send = "No";
                }
                // We have all the list item data. 
                if (dtagrid != null)
                {
                    for (gridRowCount = 0; gridRowCount < activeCount; gridRowCount++)
                    {
                        objRow[gridRowCount] = activeFlags[gridRowCount];
                    }
                    objRow[gridRowCount++] = emailName + "<" + emailAddress + ">";
                    objRow[gridRowCount++] = FrequencyDBValue;
                    objRow[gridRowCount++] = interval;
                    objRow[gridRowCount++] = Frequency;
                    objRow[gridRowCount++] = String.Format("{0:MM/dd/yyyy}", dte);
                    objRow[gridRowCount++] = String.Format("{0:MM/dd/yyyy}", listItem[dteField]);
                    objRow[gridRowCount++] = send;
                    dtagrid.Rows.Add(objRow);

                }
                if (send.Equals("Yes"))
                {
                    bool tesetSend = true;
                    if( dtagrid != null)
                         tesetSend = false;
                    if (emailDiagCount++ < 50 && sendTestEmails)
                    {
                        try
                        {
                            String msg = String.Format("To:{0}\nFrom:{1}\nSubject:{2}\nBody:{3}\n",
                            emailAddress, listConfig._emailFrom,
                            replaceText(listConfig._emailSubject, listItem, listConfig._SharePointServerName, secondaryValues),
                            replaceText(listConfig._emailBody, listItem, listConfig._SharePointServerName, secondaryValues));
                            if (!canceled)
                            {
                                DialogResult dialogResult = MessageBox.Show(msg, "Review #" + emailDiagCount + " Ctrl C to copy - press Okay to send", MessageBoxButtons.YesNoCancel);
                                if (dialogResult == DialogResult.No)
                                {
                                    tesetSend = false;
                                }
                                if (dialogResult == DialogResult.Cancel)
                                {
                                    canceled = true;
                                    tesetSend = false;
                                }
                            }
                            else
                                tesetSend = false;
                        }
                        catch (Exception ex)
                        {
                            String Msg = @"[Email for " + emailAddress + " Failed:" + ex.Message + "]";
                            MessageBox.Show(ex.Message, "Error on " + emailAddress);
                        }
                    }
                    if (!EmailMgetFileName.Equals("") && tesetSend)
                    {
                        ServerManagement sm = getServerSetup(EmailMgetFileName);
                        try
                        {
                            var decryptor = new RijndaelMessageDecryptor();
                            SmtpClient client = new SmtpClient(sm._SMTPServerName);
                            //MailAddress from = new MailAddress(emailAddress, listConfig._emailFrom);
                            MailAddress from = new MailAddress(listConfig._emailFrom);
                            // Set destinations for the e-mail message.
                            MailAddress to = new MailAddress(emailAddress);
                            // Specify the message content.
                            MailMessage message = new MailMessage(from, to);
                            message.IsBodyHtml = true;
                            message.Body = replaceText(listConfig._emailBody, listItem, listConfig._SharePointServerName, secondaryValues);
                            message.BodyEncoding = System.Text.Encoding.UTF8;
                            message.Subject = replaceText(listConfig._emailSubject, listItem, listConfig._SharePointServerName, secondaryValues);
                            message.SubjectEncoding = System.Text.Encoding.UTF8;
                            client.Credentials = new System.Net.NetworkCredential(sm._SMTPUserId, decryptor.Decrypt(sm._SMTPPwd));
                            client.Port = Int32.Parse(sm._SMTPPort);
                            client.Send(message);
                            sentRecipients.Add(emailAddress);
                            Console.WriteLine("Email sent for " + to);
                            Console.WriteLine("Subject Line " + message.Subject);
                        }
                        catch (Exception ex)
                        {
                            String Msg = @"[Email for " + emailAddress + " Failed:" + ex.Message + "]";
                            throw new Exception(Msg, ex);
                        }
                    }

                }
            }      /// 
            return sentRecipients;
        }
Example #25
0
        /// <summary>
        /// if the grid is not null establish the display 
        /// </summary>
        /// <param name="listConfig"></param>
        /// <param name="dtagrid"></param>
        /// <returns> the new colmun count</returns>
        public int setUpDataGrid(ListConfig listConfig, DataGridView dtagrid)
        {
            int activeFieldsCount = 0; // total count of fieleds
            int activeCount = 0; // cound of teh active booena list
            int secondCount = 0;// count of the secondary list
            int baseCount = 7; // base count for the grid
            if (listConfig._ActiveFields != null)
                activeCount = listConfig._ActiveFields.Count;
            if (listConfig._secondaryFields != null)
                secondCount = listConfig._secondaryFields.Count;

            if (dtagrid== null)// we are in a ral run an not testing
                return baseCount + activeCount + secondCount;
            dtagrid.ColumnCount = baseCount + activeCount + secondCount;

            foreach (String af in listConfig._ActiveFields)
                dtagrid.Columns[activeFieldsCount++].Name = af;
            foreach (String af in listConfig._secondaryFields)
                dtagrid.Columns[activeFieldsCount++].Name = af;
            dtagrid.Columns[activeFieldsCount++].Name = listConfig._UserField;
            dtagrid.Columns[activeFieldsCount++].Name = listConfig._FrequencyField;
            dtagrid.Columns[activeFieldsCount++].Name = "Interval Calculated";
            dtagrid.Columns[activeFieldsCount++].Name = "Interval Configured";
            dtagrid.Columns[activeFieldsCount++].Name = "Run date";
            dtagrid.Columns[activeFieldsCount++].Name = "Due date";
            dtagrid.Columns[activeFieldsCount++].Name = "SendEmail?";
            dtagrid.ColumnCount = activeFieldsCount;
            for (int i = 0; i < dtagrid.ColumnCount; i++)
                dtagrid.Columns[i].ReadOnly = true;

            // clear the grid and reload it
            dtagrid.Rows.Clear();
            return activeFieldsCount;
        }