Beispiel #1
0
        /// <summary> Provides an object instance to the network. All objects will be omnipresent. </summary>
        public static void ServeOmnipresentObject(string NewUri, string NewIP, uint NewPort, MarshalByRefObject ObjectToServe)
        {
            ChannelManager.LocalUri  = NewUri;
            ChannelManager.LocalIP   = NewIP;
            ChannelManager.LocalPort = NewPort;

            //Create the channel if it doesn't exist
            if (ChannelManager.DoesChannelExist(NewUri) == false)
            {
                System.Collections.Specialized.ListDictionary ChannelProperties = new System.Collections.Specialized.ListDictionary();
                ChannelProperties.Add("port", (int)ChannelManager.LocalPort);
                ChannelProperties.Add("name", ChannelManager.LocalUri);
                ChannelProperties.Add("bindTo", ChannelManager.LocalIP);

                HttpChannel chnl = new HttpChannel(ChannelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());
                ChannelServices.RegisterChannel(chnl);

                //Need a way to see if this object is already marshaled?
                RemotingServices.Marshal(ObjectToServe, ChannelManager.LocalUri);
            }

            //Throw a fatal exception if the channel was not created
            if (ChannelManager.DoesChannelExist(ChannelManager.LocalUri) == false)
            {
                throw new Exception(String.Format("Created the channel '{0}', but it didn't show up as a registered channel", ChannelManager.LocalUri));
            }
        }
Beispiel #2
0
        private void InstallService()
        {
            Logger.Write("Installing service.");
            ProgressMessageChanged?.Invoke(this, "Installing Remotely service.");
            var serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");

            if (serv == null)
            {
                var command          = new string[] { "/assemblypath=" + Path.Combine(InstallPath, "Remotely_Agent.exe") };
                var context          = new InstallContext("", command);
                var serviceInstaller = new ServiceInstaller()
                {
                    Context          = context,
                    DisplayName      = "Remotely Service",
                    Description      = "Background service that maintains a connection to the Remotely server.  The service is used for remote support and maintenance by this computer's administrators.",
                    ServiceName      = "Remotely_Service",
                    StartType        = ServiceStartMode.Automatic,
                    DelayedAutoStart = true,
                    Parent           = new ServiceProcessInstaller()
                };

                var state = new System.Collections.Specialized.ListDictionary();
                serviceInstaller.Install(state);
                Logger.Write("Service installed.");
                serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");

                ProcessEx.StartHidden("cmd.exe", "/c sc.exe failure \"Remotely_Service\" reset= 5 actions= restart/5000");
            }
            if (serv.Status != ServiceControllerStatus.Running)
            {
                serv.Start();
            }
            Logger.Write("Service started.");
        }
Beispiel #3
0
        public static void CreateLocalChannel(string NewUri, string NewIP, uint NewPort, System.Type ObjectToBeServed, WellKnownObjectMode ObjectMode)
        {
            ChannelManager.LocalUri  = NewUri;
            ChannelManager.LocalIP   = NewIP;
            ChannelManager.LocalPort = NewPort;

            //Create the channel if it doesn't exist
            if (ChannelManager.DoesChannelExist(NewUri) == false)
            {
                System.Collections.Specialized.ListDictionary ChannelProperties = new System.Collections.Specialized.ListDictionary();
                ChannelProperties.Add("port", (int)ChannelManager.LocalPort);
                ChannelProperties.Add("name", ChannelManager.LocalUri);
                ChannelProperties.Add("bindTo", ChannelManager.LocalIP);

                HttpChannel chnl = new HttpChannel(ChannelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());
                ChannelServices.RegisterChannel(chnl);

                if (DoesWellKnowServiceExist(ObjectToBeServed.FullName) == false)
                {
                    RemotingConfiguration.RegisterWellKnownServiceType(
                        ObjectToBeServed,
                        ChannelManager.LocalUri,
                        ObjectMode);
                }
            }

            //Throw a fatal exception if the channel was not created
            if (ChannelManager.DoesChannelExist(ChannelManager.LocalUri) == false)
            {
                throw new Exception(String.Format("Created the channel '{0}', but it didn't show up as a registered channel", ChannelManager.LocalUri));
            }
        }
        // GetParameters creates a list dictionary
        // consisting of a report parameter name and a value.
        private System.Collections.Specialized.ListDictionary GetParmeters(string parms)
        {
            System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
            if (parms == null)
            {
                return(ld);  // dictionary will be empty in this case
            }

            // parms are separated by &

            char[]   breakChars = new char[] { '&' };
            string[] ps         = parms.Split(breakChars);

            foreach (string p in ps)
            {
                int iEq = p.IndexOf("=");
                if (iEq > 0)
                {
                    string name = p.Substring(0, iEq);
                    string val  = p.Substring(iEq + 1);
                    ld.Add(name, val);
                }
            }
            return(ld);
        }
Beispiel #5
0
        public frmExport1(System.Collections.Specialized.ListDictionary source)
        {
            InitializeComponent();

            sourceConfigFile         = source["ConfigurationFile"] as ConfigurationFile;
            desConfigProviderElement = new ConfigProviderElement();
        }
        protected void AddNoActivityButton_Click(object sneder, EventArgs e)
        {
            ExtraActivity activity = new ExtraActivity();
            System.Collections.Specialized.ListDictionary l = new System.Collections.Specialized.ListDictionary();

            l.Add("p_persoon", p_persoon);
            l.Add("omschrijving", activity.description);
            l.Add("locatie", activity.address);

            if(AtpRadioButton.Checked){
                l.Add("type", "ATP");
            }
            else
            {
                l.Add("type", "OP");
            }

            l.Add("ambt", activity.function);
            l.Add("omvang", activity.amount);
            l.Add("startdatum", activity.startDate);
            l.Add("heeftNevenactiviteit", activity.heeftNevenactiviteit);
            l.Add("pa_goedgekeurd", activity.goedgekeurdPA);
            l.Add("dep_goedgekeurd", activity.goedgekeurdDep);
            l.Add("dep_goedkeuring_nodig", activity.heeftDepGoedkeuringNodig);
            LinqDataSource1.Insert(l);
            NoActivitiesPanel.Visible = true;
            for (int i = 0; i < OpNevenActiviteit.Items.Count; i++)
            {
                OpNevenActiviteit.Items[i].Enabled = false;
                AtpNevenActiviteiten.Items[i].Enabled = false;
            }
            _log.Debug("User heeft aangegeven dat er geen nevenactiviteit wordt uitgevoerd");
            AddNoActivityButton.Visible = false;
        }
Beispiel #7
0
 /// <summary>
 /// Prepares properties for some of the loggers used in this system that aren't
 /// associated with a particular class but named with a <c>string</c> typed 
 /// name.
 /// </summary>
 /// <param name="loggerName"></param>
 /// <returns></returns>
 public IDictionary PrepareNamedLoggerProperties(string loggerName)
 {
     IDictionary dict = new System.Collections.Specialized.ListDictionary();
       ILog log = LogManager.GetLogger(loggerName);
       dict.Add("logger", log);
       return dict;
 }
Beispiel #8
0
        public override void LoadData(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.Name != GroupName)
            {
                throw new FormatException(String.Format("Expecting <{0}>", GroupName));
            }

            keys = new System.Collections.Specialized.ListDictionary();
            foreach (XmlNode n in node.ChildNodes)
            {
                string name = n.Attributes ["name"].Value;
                if (CheckIfAdd(name, n))
                {
                    string key = GetNodeKey(name, n);
                    //keys.Add (key, name);
                    keys [key] = name;
                    LoadExtraData(key, n);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Loads article template references into memory from XML file.
        /// </summary>
        /// <returns></returns>
        public static System.Collections.Specialized.ListDictionary LoadArticleTemplates()
        {
            string appKeyName = "sf_articleTemplates";

            System.Web.HttpContext context = System.Web.HttpContext.Current;

            if (context.Application[appKeyName] != null)
            {
                return((System.Collections.Specialized.ListDictionary)context.Application[appKeyName]);
            }
            else
            {
                System.Collections.Specialized.ListDictionary at = new System.Collections.Specialized.ListDictionary();
                System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
                try
                {
                    xd.Load(System.AppDomain.CurrentDomain.BaseDirectory + SFGlobal.NodeTemplateLocation + "\\" + System.Configuration.ConfigurationSettings.AppSettings["articleTemplateDefinitions"]);
                    foreach (XmlNode xn in xd["templates"])
                    {
                        at.Add(int.Parse(xn.Attributes["id"].Value), new ArticleTemplateInfo(xn.Attributes["id"].Value, xn.Attributes["name"].Value, xn.Attributes["src"].Value));
                    }
                    context.Application.Add(appKeyName, at);
                }
                catch (Exception e)
                {
                    throw new DuryTools.ErrorHandler("can't load articleTemplate XML...", e);
                }
                return(at);
            }
        }
Beispiel #10
0
        public override void LoadData(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.Name != GroupName)
            {
                throw new FormatException(String.Format("Expecting <{0}>", GroupName));
            }

            keys = new System.Collections.Specialized.ListDictionary();
            foreach (XmlNode n in node.ChildNodes)
            {
                string name = n.Attributes ["name"].Value;
                if (CheckIfAdd(name, n))
                {
                    string key = GetNodeKey(name, n);
                    if (keys.Contains(key))
                    {
                        if ((string)keys[key] != name)
                        {
                            throw new NotImplementedException("Attribute with same name but diffent value");
                        }
                    }
                    else
                    {
                        keys.Add(key, name);
                    }

                    LoadExtraData(key, n);
                }
            }
        }
        static void Main(string[] args)
        {
            // Creates and initializes a new ListDictionary.
            System.Collections.Specialized.ListDictionary listDictionary = new System.Collections.Specialized.ListDictionary();
            listDictionary.Add("Test1", "Test@123");
            listDictionary.Add("Admin", "Admin@123");
            listDictionary.Add("Temp", "Temp@123");
            listDictionary.Add("Demo", "Demo@123");
            listDictionary.Add("Test2", "Test2@123");
            listDictionary.Remove("Admin");
            if (listDictionary.Contains("Admin"))
            {
                Console.WriteLine("UserName already Esists");
            }
            else
            {
                listDictionary.Add("Admin", "Admin@123");
                Console.WriteLine("User added succesfully.");
            }

            // Get a collection of the keys.
            Console.WriteLine("UserName" + ": " + "Password");
            foreach (DictionaryEntry entry in listDictionary)
            {
                Console.WriteLine(entry.Key + ": " + entry.Value);
            }
            Console.ReadKey();
        }
        //Cria um serviço novo e registra o mesmo no caminho System\Current\Services
        public static void CreateService(string executablePath, string serviceName, string serviceDescription, string displayServiceName)
        {
            ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();

            ProcesServiceInstaller.Account = ServiceAccount.User;

            ServiceInstaller service = new ServiceInstaller();
            InstallContext   Context = new System.Configuration.Install.InstallContext();
            String           path    = String.Format("/assemblypath={0}", executablePath);

            String[] cmdline = { path };

            Context             = new System.Configuration.Install.InstallContext("", cmdline);
            service.Context     = Context;
            service.DisplayName = displayServiceName;
            service.Description = serviceDescription;
            service.ServiceName = serviceName;
            service.StartType   = ServiceStartMode.Automatic;
            service.Parent      = ProcesServiceInstaller;

            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();

            ServiceController serviceExists = new ServiceController(serviceName);

            service.Install(state);
        }
Beispiel #13
0
        public void ResetPassword(ResetPasswordRequestModel model)
        {
            using (OrgCommEntities dbc = new OrgCommEntities(DBConfigs.OrgCommConnectionString))
            {
                OrgComm.Data.Models.Member member = dbc.Members.SingleOrDefault(r => (!r.DelFlag) && r.Email.Equals(model.Email));

                if (member == null)
                {
                    throw new OrgException(1, "Invalid profile");
                }

                string password = System.Web.Security.Membership.GeneratePassword(8, 0);

                member.Salt         = SecurityHelper.GenerateBase64SaltString();
                member.PasswordHash = this.GenerateHash(member.Salt, password);

                member.UpdatedDate = DateTime.Now;

                dbc.SaveChanges();

                if (AppConfigs.MailSendMail)
                {
                    System.Collections.Specialized.ListDictionary listReplacement = new System.Collections.Specialized.ListDictionary();

                    listReplacement.Add("{password}", password);

                    MailSender.Send(AppConfigs.MailFrom, member.Email, "Reset password", listReplacement, AppConfigs.MailTemplateResetPassword);
                }
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            Toy doll = new Toy();
            doll.Make = "rubber";
            doll.Model = "barbie";
            doll.Name = "Elsa";

            Toy car = new Toy();
            car.Make = "plastic";
            car.Model = "BMW";
            car.Name = "SPUR";

            System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
            myArrayList.Add(doll);
            myArrayList.Add(car);

            System.Collections.Specialized.ListDictionary myDictionary
                = new System.Collections.Specialized.ListDictionary();

            myDictionary.Add(doll.Name, doll);
            myDictionary.Add(car.Name, car);
            foreach (object o in myArrayList)
            {
                Console.WriteLine(((Toy)o).Name);
            }

            Console.WriteLine(((Toy)myDictionary["Elsa"]).Model);
            Console.ReadLine();
        }
Beispiel #15
0
 protected void AddressBookDataGrid_Delete(System.Object sender, System.Web.UI.WebControls.DataGridCommandEventArgs args)
 {
     if (this._delete_items != null && this._delete_items.Count > 0)
     {
         System.Collections.Specialized.ListDictionary addressbook = anmar.SharpWebMail.UI.AddressBook.GetAddressbook(this.addressbookselect.Value, Application["sharpwebmail/send/addressbook"]);
         System.Data.DataTable data = GetDataSource(addressbook, false, Session["client"] as anmar.SharpWebMail.IEmailClient);
         if (data != null)
         {
             bool delete = false;
             System.Data.DataView view = data.DefaultView;
             foreach (System.String item in this._delete_items)
             {
                 view.RowFilter = System.String.Concat(data.Columns[1].ColumnName, "='", item, "'");
                 if (view.Count == 1)
                 {
                     view[0].Delete();
                     delete = true;
                 }
             }
             if (delete)
             {
                 anmar.SharpWebMail.UI.AddressBook.UpdateDataSource(data, addressbook, Session["client"] as anmar.SharpWebMail.IEmailClient);
             }
         }
     }
 }
        protected void AddAtpActivityButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                DateTime start = AtpStartDate.SelectedDate.GetValueOrDefault();
                ExtraActivity activity = new ExtraActivity(AtpAardActiviteit.Text, AtpAdresActiviteit.Text, AtpOmvangActiviteit.Text, startDate: start);

                System.Collections.Specialized.ListDictionary l = new System.Collections.Specialized.ListDictionary();
                l.Add("p_persoon", p_persoon);
                l.Add("omschrijving", activity.description);
                l.Add("locatie", activity.address);
                if (OpRadioButton.Checked)
                {
                    l.Add("type", "OP");
                }
                else
                {
                    l.Add("type", "ATP");
                }

                l.Add("ambt", activity.function);
                l.Add("omvang", activity.amount);
                l.Add("startdatum", activity.startDate);
                l.Add("heeftNevenactiviteit", true);
                l.Add("pa_goedgekeurd", false);
                l.Add("dep_goedgekeurd", false);
                l.Add("dep_goedkeuring_nodig", false);

                LinqDataSource1.Insert(l);
                _log.Info("ATP Nevenactiviteit toegevoegd");
                AtpNevenActiviteiten.Items[0].Enabled = false;
            }
        }
Beispiel #17
0
        //Cria um serviço novo e registra o mesmo no caminho System\Current\Services
        public static void CreateService(string executablePath, string serviceName, string serviceDescription, string DisplayServiceName)
        {
            string retorno = VerifyInstanceTotal(@"SYSTEM\CurrentControlSet\services\" + serviceName, "DisplayName");

            if (retorno == "")
            {
                ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();
                ProcesServiceInstaller.Account = ServiceAccount.User;

                ServiceInstaller servico = new ServiceInstaller();
                InstallContext   Context = new System.Configuration.Install.InstallContext();
                String           path    = String.Format("/assemblypath={0}", executablePath);
                String[]         cmdline = { path };

                Context             = new System.Configuration.Install.InstallContext("", cmdline);
                servico.Context     = Context;
                servico.DisplayName = DisplayServiceName;
                servico.Description = serviceDescription;
                servico.ServiceName = serviceName;
                servico.StartType   = ServiceStartMode.Automatic;
                servico.Parent      = ProcesServiceInstaller;

                System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();

                ServiceController serviceExists = new ServiceController(serviceName);

                servico.Install(state);
            }
        }
        public static void InstallService()
        {
            string serviceExecuteblePath = viewModel.InstallFolderPath + $@"\{Settings.ApplicationName}\Service\Service.exe";

            if (!File.Exists(serviceExecuteblePath))
            {
                // Add handler
                return;
            }
            try
            {
                ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();
                ProcesServiceInstaller.Account = ServiceAccount.LocalSystem;
                System.ServiceProcess.ServiceInstaller ServiceInstallerObj = new System.ServiceProcess.ServiceInstaller();
                InstallContext Context = new InstallContext();
                String         path    = $"/assemblypath={serviceExecuteblePath}";
                String[]       cmdline = { path };

                Context = new InstallContext("", cmdline);
                ServiceInstallerObj.Context     = Context;
                ServiceInstallerObj.DisplayName = "Application Service";
                ServiceInstallerObj.Description = "Service for Application";
                ServiceInstallerObj.ServiceName = "ApplicationService";
                ServiceInstallerObj.StartType   = ServiceStartMode.Automatic;
                ServiceInstallerObj.Parent      = ProcesServiceInstaller;

                System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
                ServiceInstallerObj.Install(state);
            }
            catch (Exception e)
            {
                OnInstallError?.Invoke("Error installing service." + e.Message);
            }
        }
Beispiel #19
0
        public static void SendMail(string subject, string body)
        {
            var fromAddress = new MailAddress("*****@*****.**", "iLogic");
            string fromPassword = "******";

            try
            {
                var smtp = new SmtpClient
                {
                    Host = "smtp.gmail.com",
                    Port = 587,
                    EnableSsl = true,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword)
                };

                System.Web.UI.WebControls.MailDefinition md = new System.Web.UI.WebControls.MailDefinition();
                md.From = "*****@*****.**";
                md.IsBodyHtml = false;
                md.Subject = subject;
                System.Collections.Specialized.ListDictionary replacements = new System.Collections.Specialized.ListDictionary();
                MailMessage msg = md.CreateMailMessage("[email protected],[email protected]", replacements, body, new System.Web.UI.Control());
                smtp.Send(msg);
            }
            catch
            {

            }
        }
Beispiel #20
0
 public void AddParameter(string name, int value)
 {
     if (this.InputParameters == null)
     {
         this.InputParameters = new System.Collections.Specialized.ListDictionary();
     }
     this.InputParameters[name] = value;
 }
Beispiel #21
0
 public void AddParameter(string name, List <object> value)
 {
     if (this.InputList == null)
     {
         this.InputList = new System.Collections.Specialized.ListDictionary();
     }
     this.InputList[name] = value;
 }
Beispiel #22
0
        /// <summary>
        /// Prepares the logger properties.
        /// This method should be called by every class who wants to be logged to
        /// prepare the logging properties.
        /// </summary>
        /// <param name="objType">Type of the object.</param>
        /// <returns>A dictionary with the properties of the logger.</returns>
        public IDictionary PrepareLoggerProperties(Type objType)
        {
            IDictionary dict = new System.Collections.Specialized.ListDictionary();
            ILog        log  = LogManager.GetLogger(objType);

            dict.Add("logger", log);
            return(dict);
        }
Beispiel #23
0
 public EPForm(ExecuteSql ExecuteSql, System.Collections.Specialized.ListDictionary ComponentAttributes, string ClinicalContext)
 {
     InitializeComponent();
     this.ExecuteSql          = ExecuteSql;
     this.ComponentAttributes = ComponentAttributes;
     this.ClinicalContext     = ClinicalContext;
     Initialize();
 }
Beispiel #24
0
        private void rmiService_Install_Click(object sender, EventArgs e)
        {
            try
            {
                InstallContext          install = new InstallContext();
                ServiceProcessInstaller spi     = new ServiceProcessInstaller();
                ServiceInstallerEx      svi     = new ServiceInstallerEx();


                String name = Application.StartupPath + "\\ServiceManager.exe";

                String   path    = String.Format("/assemblypath=\"{0}\"", name);
                String[] cmdline = { path };

                install = new InstallContext("", cmdline);

                install.Parameters["assemblypath"] += " -s";

                spi.Account   = ServiceAccount.LocalSystem;
                svi.StartType = ServiceStartMode.Automatic;

                svi.ServiceName = Program.ServiceName;
                svi.DisplayName = Program.ServiceTitle;
                svi.Description = "Runs and protecting specific applications.";
                svi.Context     = install;

                //Nicht verzögern, also so früh wie möglich starten
                svi.DelayedAutoStart = false;
                svi.Parent           = spi;

                //Internet wird benötigt
                svi.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" };

                svi.FailCountResetTime = 60 * 60 * 24;
                svi.FailRebootMsg      = "Whitney Houston! We have a problem";
                svi.FailureActions.Add(new FailureAction(RecoverAction.Restart, 60000));
                svi.FailureActions.Add(new FailureAction(RecoverAction.Restart, 60000));
                svi.FailureActions.Add(new FailureAction(RecoverAction.Restart, 60000));

                //svi.StartOnInstall = true;

                System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
                svi.Install(state);

                svi.UpdateServiceConfig(null, null);

                tmRefresh_Tick(null, null);

                rmServiceRefresh_Tick(null, null);

                MessageBox.Show("Service installed.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Service can not be installed.\r\n" + ex.Message, "Error on installation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public static ControlsValidate?ValidateData(Control FirstControl, System.Collections.Specialized.ListDictionary ControlsArray)
        {
            ControlsValidate  ErrorInControl;
            ValidationError   Validate = null;
            BindingExpression BExp     = null;
            Control           Tmp      = FirstControl;

            while (Tmp != null)
            {
                if (Tmp != null && Tmp.IsVisible == false && (Tmp.Name == "TextBoxCurrentReadDate" || Tmp.Name == "TextBoxCurrentRead"))
                {
                    Tmp = ((ControlsTab)ControlsArray[Tmp]).Next;
                    continue;
                }

                if (((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxFormul || ((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxText || ((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxNumber)
                {
                    BExp = BindingOperations.GetBindingExpression((TextBox)Tmp, TextBox.TextProperty);
                }
                else
                if (((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.ComboBox)
                {
                    BExp = BindingOperations.GetBindingExpression((ComboBox)Tmp, ComboBox.SelectedIndexProperty);
                }

                if (BExp != null)
                {
                    BExp.UpdateSource();
                    if (((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxFormul || ((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxText || ((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.TextBoxNumber)
                    {
                        Validate = BindingOperations.GetBindingExpression((TextBox)Tmp, TextBox.TextProperty).ValidationError;
                    }
                    else
                    if (((ControlsTab)ControlsArray[Tmp]).Type == ControlsType.ComboBox)
                    {
                        Validate = BindingOperations.GetBindingExpression((ComboBox)Tmp, ComboBox.SelectedIndexProperty).ValidationError;
                    }
                    if (Validate != null)
                    {
                        break;
                    }
                }

                Tmp = ((ControlsTab)ControlsArray[Tmp]).Next;
            }
            if (Validate != null)
            {
                ErrorInControl.Control       = Tmp;
                ErrorInControl.Message       = Validate.ErrorContent.ToString();
                ErrorInControl.TypeOfControl = Tmp.GetType();
                return(ErrorInControl);
            }
            else
            {
                return(null);
            }
        }
Beispiel #26
0
 public static ArticleTemplateInfo GetArticleTemplate(int id)
 {
     System.Collections.Specialized.ListDictionary at = LoadArticleTemplates();
     if (at[id] == null)
     {
         throw new DuryTools.ErrorHandler("error loading template... check id {" + id.ToString() + "} or make sure articles are published");
     }
     return((ArticleTemplateInfo)at[id]);
 }
Beispiel #27
0
 private void fillTemplateSelect()
 {
     System.Collections.Specialized.ListDictionary at = SFGlobal.LoadArticleTemplates();
     foreach (System.Collections.DictionaryEntry de in at)
     {
         ArticleTemplateInfo ati = (ArticleTemplateInfo)de.Value;
         articleTemplateID.Items.Add(new ListItem(ati.Name, ati.ID));
     }
 }
Beispiel #28
0
        public AgentDialog(Agent agentClicked, System.Collections.Specialized.ListDictionary population, GUI mainGUI)
        {
            InitializeComponent();

            this.Owner = mainGUI;

            agentPropertyGrid.SelectedObject = agentClicked;

            this.Text = "Agent Parameters: " + agentClicked.ID;
        }
        public TestT BuildFrom(MethodInfo method, TestT parentSuite)
        {
            TestSuite testT = new TestSuite(method.Name);
            NUnitFramework.ApplyCommonAttributes(method, testT);

            ArrayList hierachyNodeList = new ArrayList();
            foreach (ProviderReference reference in GetBuildersFor(method, parentSuite))
            {
                System.Collections.Specialized.ListDictionary contextProperties
                     = new System.Collections.Specialized.ListDictionary();
                //테스트 함수에 지정된 특성값을 계층노드의 속성으로 복사합니다.
                foreach (DictionaryEntry entry in testT.Properties)
                {
                    if ((string)entry.Key != DESCRIPTION
                        && (string)entry.Key != CATEGORIES)
                    {
                        contextProperties[entry.Key] = entry.Value;
                    }
                }

                HierachyNode baseNode = new HierachyNode(method.Name);
                baseNode = reference.GetInstance(baseNode, contextProperties) as HierachyNode;
                if (baseNode != null)
                {
                    hierachyNodeList.Add(baseNode);
                }
            }

            ArrayList testSuiteList = new ArrayList();
            foreach (HierachyNode hierachyNode in hierachyNodeList)
            {
                TestSuite testSuite = new TestSuite(hierachyNode.Name);
                this.BuildTestSuiteTree(method, ref testSuite, hierachyNode);
                testSuiteList.Add(testSuite);
            }

            if (testSuiteList.Count > 0)
            {
                if (testSuiteList.Count == 1)
                {
                    testT = testSuiteList[0] as TestSuite;
                }
                else
                {
                    testT = new TestSuite(method.Name);
                    NUnitFramework.ApplyCommonAttributes(method, testT);
                    foreach (TestSuite testSuite in testSuiteList)
                    {
                        testT.Add(testSuite);
                    }
                }
            }

            return testT;
        }
        public async Task<bool> SendForgottenPwdEmail(string strTo, string newPassword)
        {
            System.Collections.Specialized.ListDictionary replacements = new System.Collections.Specialized.ListDictionary();
            ForgottenPwdMailConfig config = MailConfigProvider.GetConfiguration<ForgottenPwdMailConfig>();
            replacements.Add("<%Password%>", newPassword);

            DisciturMailDef<ForgottenPwdMailConfig> md = new DisciturMailDef<ForgottenPwdMailConfig>(replacements);
            MailMessage mm = md.CreateMailMessage(strTo);

            return await this.SendEmail(mm, config.From, null);
        }
Beispiel #31
0
        private void Load(System.Xml.XmlDocument BrowserFile)
        {
            Lookup        = new System.Collections.Specialized.ListDictionary();
            DefaultLookup = new System.Collections.Specialized.ListDictionary();
            RefNodes      = new List <Node>();
            System.Xml.XmlNode node;
            //I know this might allocate more nodes then needed but never less.
            Nodes = new Node[BrowserFile.DocumentElement.ChildNodes.Count];
            for (int a = 0; a <= BrowserFile.DocumentElement.ChildNodes.Count - 1; a++)
            {
                node = BrowserFile.DocumentElement.ChildNodes[a];

                if (node.NodeType == System.Xml.XmlNodeType.Comment)
                {
                    continue;
                }
                Nodes[a]          = new Node(node);
                Nodes[a].FileName = FileName;
                if (Nodes[a].NameType != NodeType.DefaultBrowser)
                {
                    //fxcop sugguested this was faster then
                    //Nodes[a].refID != string.Empty
                    if (Nodes[a].RefId.Length > 0)
                    {
                        RefNodes.Add(Nodes[a]);
                    }
                    else if (Lookup.Contains(Nodes[a].Id) == false)
                    {
                        Lookup.Add(Nodes[a].Id, a);
                    }
                    else
                    {
                        throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
                    }
                }
                else
                {
                    //fxcop sugguested this was faster then
                    //Nodes[a].refID != string.Empty
                    if (Nodes[a].RefId.Length > 0)
                    {
                        RefNodes.Add(Nodes[a]);
                    }
                    else if (DefaultLookup.Contains(Nodes[a].Id) == false)
                    {
                        DefaultLookup.Add(Nodes[a].Id, a);
                    }
                    else
                    {
                        throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
                    }
                }
            }
        }
Beispiel #32
0
        public void Initialize(ExecuteSql ExecuteSql, System.Collections.Specialized.ListDictionary ComponentAttributes, string ClinicalContext)
        {
            this.ExecuteSql          = ExecuteSql;
            this.ComponentAttributes = ComponentAttributes;
            this.ClinicalContext     = ClinicalContext;

            if (Initialized != null)
            {
                Initialized(this, new EventArgs());
            }
        }
Beispiel #33
0
		private void Load(System.Xml.XmlDocument BrowserFile)
		{
			Lookup = new System.Collections.Specialized.ListDictionary();
			DefaultLookup = new System.Collections.Specialized.ListDictionary();
			RefNodes = new List<Node>();
			System.Xml.XmlNode node;
			//I know this might allocate more nodes then needed but never less.
			Nodes = new Node[BrowserFile.DocumentElement.ChildNodes.Count];
			for (int a = 0;a <= BrowserFile.DocumentElement.ChildNodes.Count - 1;a++)
			{
				node = BrowserFile.DocumentElement.ChildNodes[a];

				if (node.NodeType == System.Xml.XmlNodeType.Comment)
				{
					continue;
				}
				Nodes[a] = new Node(node);
				Nodes[a].FileName = FileName;
				if (Nodes[a].NameType != NodeType.DefaultBrowser)
				{
					//fxcop sugguested this was faster then
					//Nodes[a].refID != string.Empty
					if (Nodes[a].RefId.Length > 0)
					{
						RefNodes.Add(Nodes[a]);
					}
					else if (Lookup.Contains(Nodes[a].Id) == false)
					{
						Lookup.Add(Nodes[a].Id, a);
					}
					else
					{
						throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
					}
				}
				else
				{
					//fxcop sugguested this was faster then
					//Nodes[a].refID != string.Empty
					if (Nodes[a].RefId.Length > 0)
					{
						RefNodes.Add(Nodes[a]);
					}
					else if (DefaultLookup.Contains(Nodes[a].Id) == false)
					{
						DefaultLookup.Add(Nodes[a].Id, a);
					}
					else
					{
						throw new nBrowser.Exception("Duplicate ID found \"" + Nodes[a].Id + "\"");
					}
				}
			}
		}
Beispiel #34
0
        private void chineseControl(Control ctrl)
        {
            if (filterDic == null)
            {
                filterDic = new System.Collections.Specialized.ListDictionary();
                filterDic.Add("", "");
                filterDic.Add("等于=", "equals");
                filterDic.Add("不等于<>", "does not equal");
                filterDic.Add("大于>", "is greater than");
                filterDic.Add("大于或等于>=", "is greater than or equal to");
                filterDic.Add("小于<", "is less than");
                filterDic.Add("小于或等于<=", "is less than or equal to");
                filterDic.Add("空值NULL", "blanks");
                filterDic.Add("非空值Not NULL", "non blanks");
                filterDic.Add("包含Like", "like");
                filterDic.Add("不包含Not Like", "not like");
            }
            Control child = GetChildControlByName(ctrl.Controls, "btnCancel");

            if (child != null)
            {
                child.Text = "取消";
            }
            child = GetChildControlByName(ctrl.Controls, "btnOK");
            if (child != null)
            {
                child.Text = "确定";
            }
            child = GetChildControlByName(ctrl.Controls, "rbOr");
            if (child != null)
            {
                child.Text = "或";
            }
            child = GetChildControlByName(ctrl.Controls, "rbAnd");
            if (child != null)
            {
                child.Text = "与";
            }
            child = GetChildControlByName(ctrl.Controls, "label1");
            if (child != null)
            {
                child.Text = "条件:";
            }
            child = GetChildControlByName(ctrl.Controls, "piFirst");
            if (child != null)
            {
                chineseComboEdit(child);
            }
            child = GetChildControlByName(ctrl.Controls, "piSecond");
            if (child != null)
            {
                chineseComboEdit(child);
            }
        }
Beispiel #35
0
        private void gridView_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
        {
            //------------------------------------------------------------------------------------------------------------//

            //这段代码是我专用于给xtrGrid加一个点中空地方时显示的菜单,我在这里加入了它的打印功能
            if (e.Menu == null)
            {
                /*
                 *  if(e.HitInfo.InRow == false && (sender is DevExpress.XtraGrid.Views.Grid.GridView))
                 *  {
                 *   gCExport = ((DevExpress.XtraGrid.Views.Grid.GridView)sender).GridControl;
                 *   Point pt = e.Point;
                 *   pt.X = pt.X + gCExport.Location.X;
                 *   pt.Y = pt.Y + gCExport.Location.Y;
                 *   popupMenu1.ShowPopup(gCExport.PointToScreen(pt));
                 *  }
                 *
                 */
                return;
            }

            //------------------------------------------------------------------------------------------------------------//
            //汉化xtraGrid的菜单
            System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterSum, "总和");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterMin, "最小值");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterMax, "最大值");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterCount, "数量");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterAverage, "平均值");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuFooterNone, "无");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnSortAscending, "上升排序");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnSortDescending, "下降排序");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnGroup, "分组");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnUnGroup, "取消分组");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnColumnCustomization, "自定义");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnBestFit, "最佳宽度");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnFilter, "过滤");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnClearFilter, "清除过滤");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnBestFitAllColumns, "所有列最佳宽度");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuGroupPanelFullExpand, "全部展开");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuGroupPanelFullCollapse, "全部收缩");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuGroupPanelClearGrouping, "清除分组");
            ld.Add(DevExpress.XtraGrid.Localization.GridStringId.MenuColumnGroupBox, "窗口式分组");

            foreach (DevExpress.Utils.Menu.DXMenuItem item in e.Menu.Items)
            {
                Object val = ld[item.Tag];
                if (val != null)
                {
                    item.Caption = val.ToString();
                }
            }
        }
        public frmViewInsertScript(System.Collections.Specialized.ListDictionary source)
        {
            InitializeComponent();

            sourceConfigFile = (source["ConfigurationFile"] as ConfigurationFile).Clone <ConfigurationFile>();

            txtFileName.Text           = sourceConfigFile.FileName;
            txtSQLInserts.TitleVisible = true;


            Build();
        }
Beispiel #37
0
 private System.Data.DataTable GetData()
 {
     if (this._book_name != null && this._book_name.Length > 0)
     {
         System.Collections.Specialized.ListDictionary addressbook = anmar.SharpWebMail.UI.AddressBook.GetAddressbook(this._book_name, Application["sharpwebmail/send/addressbook"]);
         if (addressbook != null)
         {
             return(anmar.SharpWebMail.UI.AddressBook.GetDataSource(addressbook, false, Session["client"] as anmar.SharpWebMail.IEmailClient));
         }
     }
     return(null);
 }
Beispiel #38
0
        public bool DeployService()
        {
            try
            {
                Installer installer = new Installer();


                ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
                EventLogInstaller       customEventLogInstaller;

                processInstaller.Account = _settings.ServiceAccount;

                if (processInstaller.Account == ServiceAccount.User)
                {
                    processInstaller.Username = _settings.ServiceAccountUserName;
                    processInstaller.Password = _settings.ServiceAccountPassword;
                }

                ServiceInstaller serviceInstaller = new ServiceInstaller();
                InstallContext   Context          = new System.Configuration.Install.InstallContext();
                String           path             = String.Format("/assemblypath={0}", _settings.ServiceExecutalePath);//String.Format("/assemblypath={0}", @"<<path of executable of window service>>");
                String[]         cmdline          = { path };

                Context = new System.Configuration.Install.InstallContext("", cmdline);
                serviceInstaller.Context     = Context;
                serviceInstaller.DisplayName = _settings.ServiceName;
                serviceInstaller.ServiceName = _settings.ServiceName;
                serviceInstaller.Description = _settings.ServiceDescription;
                serviceInstaller.StartType   = _settings.ServiceStartMode;

                //usama
                serviceInstaller.Parent = processInstaller;

                // Create an instance of 'EventLogInstaller'.
                customEventLogInstaller = new EventLogInstaller();
                // Set the 'Source' of the event log, to be created.
                customEventLogInstaller.Source = "customTayaLog";
                // Set the 'Event Log' that the source is created in.
                customEventLogInstaller.Log = "TayaApplication";
                // Add myEventLogInstaller to 'InstallerCollection'.

                //serviceInstaller.Installers.Add(customEventLogInstaller);
                System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
                serviceInstaller.Install(state);

                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex, "ServiceUtility.DeployService", LogType.Watcher);
                return(false);
            }
        }
Beispiel #39
0
        public ListaMessaggiUC()
        {
            InitializeComponent();

            System.Collections.IDictionary args = new System.Collections.Specialized.ListDictionary();
            args.Add("currentUser", Login.Instance.CurrentLogin().LoginName);

            var prop = new CustomControlProperties
            {
                AllowUpdate = DefaultableBoolean.True,
                AllowDelete = DefaultableBoolean.True
            };
            lista.Tag = prop;

            var propVerifica = new CustomControlProperties { AlwaysEnable = true };
            btnElaboraInfoMessaggi.Tag = propVerifica;
        }
        public async Task<bool> SendActivationEmail(string strTo, string username, string newPassword, string activationKey, string absoluteURL)
        {
            System.Collections.Specialized.ListDictionary replacements = new System.Collections.Specialized.ListDictionary();

            ActivationMailConfig config = MailConfigProvider.GetConfiguration<ActivationMailConfig>();
            string fromURL = string.IsNullOrEmpty(config.ActivationURL) ? absoluteURL : config.ActivationURL;

            replacements.Add("<%Username%>", username);
            replacements.Add("<%Password%>", newPassword);
            replacements.Add("<%ActivationKey%>", activationKey);
            replacements.Add("<%ActivationUrl%>", @fromURL);
            replacements.Add("<%ActivationPath%>", @config.ActivationPath);

            DisciturMailDef<ActivationMailConfig> md = new DisciturMailDef<ActivationMailConfig>(replacements);
            MailMessage mm = md.CreateMailMessage(strTo);

            return await this.SendEmail(mm, config.From, null);
        }
        /// <summary>
        /// Changes the item ID.
        /// </summary>
        /// <param name="fromItemId">From item id.</param>
        /// <param name="fromUnitId">From unit id.</param>
        /// <param name="toItemId">To item id.</param>
        /// <param name="toUnitId">To unit id.</param>
        /// <returns></returns>
        public static String ChangeItemID(int fromItemId, int fromUnitId, int toItemId, int toUnitId)
        {
            System.Collections.Specialized.ListDictionary Parms = new System.Collections.Specialized.ListDictionary();
            Parms.Add("@toItemID", toItemId);
            Parms.Add("@fromitemID",fromItemId);
            Parms.Add("@fromUnitID",fromUnitId);
            Parms.Add("@toUnitID" ,toUnitId);

            try
            {
                Item items = new Item();
                items.LoadFromSql("procChangeItemID", Parms);
                //return items.DataRow.ItemArray[0].ToString();
                return "Successful";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        /// <summary>
        /// Set things in motion so your service can do its work.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            if (mediaServer != null) this.OnStop();
            mediaServer = new MediaServerCore("Intel's Media Server (" + System.Windows.Forms.SystemInformation.ComputerName + ")");

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();
            channelProperties.Add("port", 12329);

            HttpChannel channel = new HttpChannel(channelProperties,
                new SoapClientFormatterSinkProvider(),
                new SoapServerFormatterSinkProvider());

            //channel = new TcpChannel(12329);
            ChannelServices.RegisterChannel(channel);

            RemotingConfiguration.ApplicationName = "IntelUPnPMediaServer";
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(UPnPMediaServer),
                "UPnPMediaServer.soap",
                WellKnownObjectMode.Singleton);
        }
Beispiel #43
0
        public override void LoadData(XmlNode node)
        {
            if (node == null)
                throw new ArgumentNullException ("node");

            if (node.Name != GroupName)
                throw new FormatException (String.Format ("Expecting <{0}>", GroupName));

            keys = new System.Collections.Specialized.ListDictionary ();
            foreach (XmlNode n in node.ChildNodes) {
                string name = n.Attributes ["name"].Value;
                if (CheckIfAdd (name, n)) {
                    string key = GetNodeKey (name, n);
                    if (keys.Contains (key)) {
                        if ((string) keys[key] != name)
                            throw new NotImplementedException ("Attribute with same name but diffent value");
                    } else {
                        keys.Add (key, name);
                    }

                    LoadExtraData (key, n);
                }
            }
        }
 public DataTable TransactionReport(int storeId, DateTime dt1, DateTime dt2, string selectedType, BackgroundWorker bw)
 {
     System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
     ld.Add("@storeid", storeId);
     ld.Add("@fromdate", dt1);
     ld.Add("@todate", dt2);
     this.LoadFromSql("GetTransactionDetails", ld, CommandType.StoredProcedure);
     return this.DataTable;
 }
        public static int GetNextSequenceNo(int documentTypeId, int accountId, int fiscalYearId)
        {
            int sequenceNo;
            System.Collections.Specialized.ListDictionary Parms = new System.Collections.Specialized.ListDictionary();
            Parms.Add("@DocumentTypeID", documentTypeId);
            Parms.Add("@AccountID", accountId);
            Parms.Add("@FiscalYearID", fiscalYearId);
            Parms.Add("@SequenceNo", 0);

            DocumentType documentType = new DocumentType();
            documentType.LoadFromSql("[sp_GetNextSequence]", Parms, CommandType.StoredProcedure);
            sequenceNo = documentType.Getint("SequenceNo");
            return sequenceNo;
        }
		//[Test]
		// User should uncomment if they want to see the Performance Comparison
		public void Performance() 
		{
			// set the hashtable and SequencedHashMap to be the 
			IDictionary hashtable;
			IDictionary sequenced;
			IDictionary list;

			int numOfRuns = 1;

			int numOfEntries = Int16.MaxValue;

			long hashStart;
			long[] hashPopulateTicks = new long[numOfRuns];
			long[] hashItemTicks = new long[numOfRuns];

			long seqStart;
			long[] seqPopulateTicks = new long[numOfRuns];
			long[] seqItemTicks = new long[numOfRuns];

			long listStart;
			long[] listPopulateTicks = new long[numOfRuns];
			long[] listItemTicks = new long[numOfRuns];

			for (int runIndex = 0; runIndex < numOfRuns; runIndex++) 
			{
				object key;
				object value;
				hashtable = new Hashtable();
				sequenced = new SequencedHashMap();
				list = new System.Collections.Specialized.ListDictionary();

				hashStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					hashtable.Add("test" + i, new object());
				}

				hashPopulateTicks[runIndex] = DateTime.Now.Ticks - hashStart;

				hashStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = hashtable[key];
				}

				hashItemTicks[runIndex] = DateTime.Now.Ticks - hashStart;

				hashtable.Clear();

				seqStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					sequenced.Add("test" + i, new object());
				}

				seqPopulateTicks[runIndex] = DateTime.Now.Ticks - seqStart;

				seqStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = sequenced[key];
				}

				seqItemTicks[runIndex] = DateTime.Now.Ticks - seqStart;

				sequenced.Clear();

				listStart = DateTime.Now.Ticks;

				for(int i = 0; i < numOfEntries; i++) 
				{
					list.Add("test" + i, new object());
				}

				listPopulateTicks[runIndex] = DateTime.Now.Ticks - listStart;

				listStart = DateTime.Now.Ticks;
				for(int i = 0; i < numOfEntries; i++) 
				{
					key = "test" + i;
					value = list[key];
				}

				listItemTicks[runIndex] = DateTime.Now.Ticks - listStart;


				list.Clear();

			}
			
			for (int runIndex = 0; runIndex < numOfRuns; runIndex++) 
			{
				decimal seqPopulateOverhead = ( (decimal)seqPopulateTicks[runIndex] /(decimal)hashPopulateTicks[runIndex] );
				decimal seqItemOverhead = ( (decimal)seqItemTicks[runIndex] / (decimal)hashItemTicks[runIndex] );

				string errMessage = "SequenceHashMap vs Hashtable:";
				errMessage += "\n POPULATE:";
				errMessage += "\n\t seqPopulateTicks[" + runIndex + "] took " + seqPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t hashPopulateTicks[" + runIndex + "] took " + hashPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + seqPopulateOverhead .ToString() ;
				errMessage += "\n ITEM:";
				errMessage += "\n\t seqItemTicks[" + runIndex + "] took " + seqItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t hashItemTicks[" + runIndex + "] took " + hashItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + seqItemOverhead .ToString() ;
				
				System.Console.Out.WriteLine(errMessage);
				
				decimal listPopulateOverhead = ( (decimal)listPopulateTicks[runIndex] / (decimal)seqPopulateTicks[runIndex] );
				decimal listItemOverhead = ( (decimal)listItemTicks[runIndex] / (decimal)seqItemTicks[runIndex] );

				errMessage = "ListDictionary vs SequenceHashMap:";
				errMessage += "\n POPULATE:";
				errMessage += "\n\t listPopulateTicks[" + runIndex + "] took " + listPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t seqPopulateTicks[" + runIndex + "] took " + seqPopulateTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + listPopulateOverhead.ToString();
				errMessage += "\n ITEM:";
				errMessage += "\n\t listItemTicks[" + runIndex + "] took " + listItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t seqItemTicks[" + runIndex + "] took " + seqItemTicks[runIndex] + " ticks.";
				errMessage += "\n\t for an overhead of " + listItemOverhead .ToString() ;
				
				System.Console.Out.WriteLine(errMessage);

			}
		}
        /* REIMPLIMENTATION OF getTableDescription using sp_MS procedures */
        public override FieldDescriptor[] getTableDescription(string table)
        {
            try
            {
                System.Collections.Specialized.ListDictionary al = new System.Collections.Specialized.ListDictionary();
                System.Data.Odbc.OdbcDataReader odr = this._dbObj.getNewConnection().GetDatabaseConnector().getResult(String.Format("sp_MShelpcolumns '{0}'", this._dbObj.GetDatabaseConnector().DoTopLevelSqlTranslations(ref table)));

                Database iterationWorker = this._dbObj.getNewConnection();
                while (odr.Read())
                {
                    string fieldname = Convert.ToString(odr["col_name"]);
                    string fieldTypeStr = Convert.ToString(odr["col_typename"]);
                    int fieldMaxLen = Convert.ToInt32(odr["col_len"]);
                    string fieldAllowNull = Convert.ToString(odr["col_null"]); //0 = no, 1 = nullable
                    string isIdentity = Convert.ToString(odr["col_identity"]);
                    string isPrimaryKey = (this.isPKCol(this._dbObj.GetDatabaseConnector().DoTopLevelSqlTranslations(ref table),fieldname) == true) ? "True" : "False";
                    FieldDescriptor fd = new FieldDescriptor();
                    fd.name = fieldname;
                    fd.type = this.typeStrToField(fieldTypeStr).type;

                    fd.maxlen = fieldMaxLen;
                    System.Collections.ArrayList modList = new System.Collections.ArrayList();
                    if (fieldAllowNull.ToLower().Equals("false"))
                        modList.Add(ABSTRACTFIELDMODIFIERS.NotNull);
                    if (isPrimaryKey.ToLower().Equals("true"))
                        modList.Add(ABSTRACTFIELDMODIFIERS.PrimaryKey);
                    if (isIdentity.ToLower().Equals("true"))
                        modList.Add(ABSTRACTFIELDMODIFIERS.AutoIncrement);

                    fd.modifiers = new ABSTRACTFIELDMODIFIERS[modList.Count];
                    Array.Copy(modList.ToArray(), fd.modifiers, modList.Count);
                    //fd.defaultval = fieldDefaultVal;
                    al.Add(fd.name, fd);
                }

                odr = null;

                //odr.Close();
                FieldDescriptor[] returnArray = new FieldDescriptor[al.Count];
                //Array.Copy(al.Values., returnArray, al.Count);

                al.Values.CopyTo(returnArray, 0);
                if (returnArray.Length == 0) return null;
                //Array.Reverse(returnArray);

                return returnArray;
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.Print(e.Message);
            }
            return null;
        }
        public DataTable GetCurrentSOHAsOfDate(int itemId, int storeId, DateTime date)
        {
            this.FlushData();
            System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
            ld.Add("@storeid", storeId);
            ld.Add("@month", date.Month);
            ld.Add("@year", date.Year);
            ld.Add("@days", DateTime.DaysInMonth(date.Year, date.Month));

            this.LoadFromSql("SOH", ld, CommandType.StoredProcedure);
            return this.DataTable;
        }
Beispiel #49
0
		public override void LoadData (XmlNode node)
		{
			if (node == null)
				throw new ArgumentNullException ("node");

			if (node.Name != GroupName)
				throw new FormatException (String.Format ("Expecting <{0}>", GroupName));

			keys = new System.Collections.Specialized.ListDictionary ();
			foreach (XmlNode n in node.ChildNodes) {
				string name = n.Attributes["name"].Value;
				string key = GetNodeKey (name, n);
				XMLParameter parm = new XMLParameter ();
				parm.LoadData (n);
				keys.Add (key, parm);
				LoadExtraData (key, n);
			}
		}
 public DataTable GetSOH(int storeId, int month, int year)
 {
     var ld = new System.Collections.Specialized.ListDictionary
                  {
                      {"@storeid", storeId},
                      {"@month", month},
                      {"@year", year},
                      {"@days", DateTime.DaysInMonth(year, month)}
                  };
     this.LoadFromSql("SOH", ld, CommandType.StoredProcedure);
     return this.DataTable;
 }
Beispiel #51
0
        /// <summary>
        /// ��Hashtable���ݽṹ����������ҵ��Ϣģ����Ϣ���������ѹر�ģ�飩
        /// </summary>
        /// <returns></returns>
        protected System.Collections.Specialized.ListDictionary GetAllInfoModules()
        {
            System.Collections.Specialized.ListDictionary list = new System.Collections.Specialized.ListDictionary();

            foreach (XYECOM.Configuration.ModuleInfo info in moduleConfig.ModuleItems)
            {
                if (info.State == false) continue;
                list.Add(info.EName, info.CName);
            }

            return list;
        }
Beispiel #52
0
        static void Main(string[] args)
        {

            try
            {




                //http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=7684&m=7669&ct=27111

                Console.WriteLine("Hello World");



                //**********************************************************************************************************************


                // String code
                string myString = "This is a test strong for c:\\drive";
                // must use double \\ for \
                Console.WriteLine(myString);
                // What about double quotation marks?
                string myString3 = "This is a double quote \" ";
                Console.WriteLine(myString3);
                // New line: use \n
                // List of special characters http://is.gd/escape_sequence

                // Remember strings allow substituting in variables
                string myString4 = string.Format("Make :{0} ", "Cat");

                // Can also format output - Currency format
                string myString5 = string.Format("{0:C}", 123.456);
                Console.WriteLine(myString5);

                // Currency - C, Number of digits - N, Percentage - P
                // Can build your own format {0:(###) ###-####} where the # represent the numbers in the sequence
                // http://is.gd/string_format

                // Can also use + operator mystring  +=

                // Instead of using string use stringbuilder. Uses less memory and is faster

                StringBuilder myString6 = new StringBuilder();

                for (int i = 0; i < 100; i++)
                {
                    myString6.Append("--");
                    myString6.Append(i);

                }

                Console.WriteLine(myString6);

                //various strong functions
                myString5.Substring(2, 4);
                myString5.ToUpper();
                myString5.Replace(" ", "--");
                int test = myString5.Length;
                //trim off white
                myString5.Trim();
                //Can chain commands 
                int test2 = myString5.Trim().Length;
                // Strong class hsa lots of methods. Its worth learning them.

                // text reading code
                StreamReader myReader = new StreamReader("Values.txt");
                string line = "";

                while (line != null)
                {
                    line = myReader.ReadLine();
                    if (line != null)
                        Console.WriteLine(line);

                }

                myReader.Close();

                //**********************************************************************************************************************


                //Reference assembles
                //Right click project name
                //	Assembly
                //o	Framework
                //o	Browse, browse
                //o	Goto dll
                //	Recheck reference list in solution explorer
                //	Can now use its classes but might need to include the namespace



                //**********************************************************************************************************************


                //Dates and Times

                DateTime myValue = DateTime.Now;
                Console.WriteLine(myValue);
                Console.WriteLine(myValue.ToString()); //same as above
                Console.WriteLine(myValue.ToShortDateString());
                Console.WriteLine(myValue.ToShortTimeString());
                Console.WriteLine(myValue.ToLongDateString());

                // Date math
                DateTime myValue2 = myValue.AddDays(3);
                Console.WriteLine(myValue2);
                // add includes days months years hours minutes etc
                // Can chain link calls like with strings
                Console.WriteLine(myValue2.AddYears(5).ToShortDateString());
                // Just give me the month
                Console.WriteLine(myValue2.Month);
                //Give me day of the week
                Console.WriteLine(myValue2.DayOfWeek);

                //Date constructor
                DateTime myBirthday = new DateTime(1969, 12, 7);

                //Date differences
                TimeSpan MyAge = DateTime.Now.Subtract(myBirthday);
                Console.WriteLine(MyAge);



                //**********************************************************************************************************************

                //Classes
                // See outside this block to see car class




                //Class enhancements
                // Static
                //Only one instance. Does not need to be instantiated.

                //Virtual
                //Can be overwritten by child implementation. But doesn’t have to be.

                //Abstract
                //Must be overwritten by child implementation. Does not provide functionality but instead serves as a placeholder/template to guide child class design.

                //Public
                //MoM can be viewed by external users of the class

                //Private
                //A MoM describe as private can be used in this class but not is visible to outside users of the class. Used for helper functions.

                //Override
                //Overrides the method or member of the parent class with a method or member preferred in the child class.

                //Void
                //No return type expected.

                //Interface
                //Life an abstract class. But child can inherit multiple interfaces.

                //Sealed
                //No children are allowed





                Car myNewCar = new Car();

                //setting properties
                myNewCar.Make = "toyota";
                myNewCar.Model = "Corola";
                myNewCar.Year = 1971;
                myNewCar.Color = "White";

                //getting property
                Console.WriteLine(myNewCar.Make);

                Console.WriteLine(myNewCar.DetermineMarketValue());



                // Shorthand class set up and putting values into members
                // Object initaliser syntax:
                Car car1 = new Car() { Make = "fast", Model = "red", Color = "blue", Year = 1990 };



                //Static classes dont require instantiation
                MyStatic.Year = 7;

                Console.WriteLine(MyStatic.Year);

                //Here in bike that inherits from vehicle
                bike MyBike = new bike();
                MyBike.size = 7;

                //Can instantiate abstract classes
                //tool mytool = new tool();
                // but can instantiate an object of a class that inherits from the abstract class
                hammer myhammer = new hammer();
                myhammer.weight = 78;





                //**********************************************************************************************************************

                //Call in  procedure
                string myLine = superSecretFormula();




                // double tab for code snippet

                //**********************************************************************************************************************

                Superhero myHero = Superhero.batman;

                // can use tab tab to speed up switch statements and then enter enter after chossing my hero


                string uservalue = "robin";

                Superhero myvalue;



                //tryparse trys to conver uservalue to type superhero and if so puts that value into myvalue
                if (Enum.TryParse<Superhero>(uservalue, true, out myvalue))
                {
                    switch (myvalue)
                    {
                        case Superhero.batman:
                            Console.WriteLine("batman");
                            break;
                        case Superhero.robin:
                            Console.WriteLine("robin");
                            Console.WriteLine(myvalue);
                            break;
                        case Superhero.superman:
                            Console.WriteLine("superman");
                            break;
                        default:
                            break;
                    }
                }


                //**********************************************************************************************************************

                // Collections

                //Old school collections are not strongly typed. So you can dump any sort of class in them

                //old array definition
                string[] banes = { "bob", "jane" };


                //Arraylist
                System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();

                myArrayList.Add(myhammer);
                myArrayList.Add(MyBike);
                myArrayList.Add(myNewCar);

                //Have to cast the output object o to type car. This works fine when it is a car but not when something else = crash
                //foreach (object o in myArrayList)
                //{
                //    Console.WriteLine(((Car)o).Make);

                //}

                //Dictionary is like a list but you put an index item at the front to make it easy to find

                System.Collections.Specialized.ListDictionary myDictionary = new System.Collections.Specialized.ListDictionary();


                myDictionary.Add(myNewCar.Make, myNewCar);




                //New school collections have strongly typed collection objects. This limits what you can put in the array
                // The type os the collection is between angle brackets
                // comes form using systems.collections.generic

                // Generic list

                List<Car> myList = new List<Car>();

                myList.Add(myNewCar);

                foreach (Car car in myList)
                {
                    Console.WriteLine(car.Model);
                }



                //Generic dictionary

                Dictionary<string, Car> myDictionary3 = new Dictionary<string, Car>();


                myDictionary3.Add(myNewCar.Make, myNewCar);
                Console.WriteLine(myDictionary3["toyota"].Model);
                

                // You can use initialiser syntax also in collections
                List<Car> myList2 = new List<Car>(){
                    new Car {Make = "fast", Model = "red"},
                    new Car {Make = "fast2", Model = "red3231"},
                    new Car {Make = "fast3", Model = "red2"}
                };



                //**********************************************************************************************************************

                // For loops
                for (int i = 0; i < 11; i++)
                {

                }


                for (int k = 0; k < 12; k++)
                {

                }


                // While loops
                int w = 0;
                while (w < 12)
                {
                    w++;
                }

                //**********************************************************************************************************************
                // Switch statement

                int answer = 6;

                switch (answer)
                {
                    case 1:
                        Console.WriteLine("answered 1");
                        break;
                    case 2:
                        Console.WriteLine("answered 2");
                        break;
                    case 6:
                        Console.WriteLine("answered 6");
                        break;
                    default:
                        break;
                }


             //**********************************************************************************************************************



                //Dont use cout, using console class
                Console.WriteLine(myLine);
                Console.WriteLine(superSecretFormula2("Jack"));
                Console.ReadLine();

                //**********************************************************************************************************************
                // Error handling
                
                // Look at the class at the far right of new creation. This lists common exception throws
                // Can put them below in your exception check list
                // need also a finally to tidy up erros anddata conections

                // error handling especially important in dealing with external resources
                // deal with most detailed exceptions first before defaulting to more general exception clauses
                // Dont bother the user if you dont have to



            }
            catch (DirectoryNotFoundException e)
            {
                Console.WriteLine("Coulnd find directory");
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("Coulnd find file");
            }
            catch (Exception e)
            {
                Console.WriteLine(" error found {0} ", e.Message);
            }
            finally
            {
                Console.WriteLine(" clean up");
            
            }


        }
 public DataTable ConsumptionTrendByMonth(int storeId, int year, int programID, BackgroundWorker bw)
 {
     // Dont Iterate
     DataTable dtbl = new DataTable();
     System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
     ld.Add("@storeid", storeId);
     ld.Add("@year", year);
     this.LoadFromSql("GetConsumptionTrendByMonth", ld, CommandType.StoredProcedure);
     return this.DataTable;
 }
        public DataTable GetBinCard2(int storeID, int itemID, int year, int unitID)
        {
            var ld = new System.Collections.Specialized.ListDictionary();
            ld.Add("@StoreID", storeID);
            ld.Add("@ItemID", itemID);
            ld.Add("@Year", year);
            ld.Add("@UnitID", unitID);

            LoadFromSql("rpt_BincardByUnit", ld, CommandType.StoredProcedure);
            //return this.DataTable;
            // Set the balance
            int balance = (int)GetBeginningBalance(year, itemID, storeID);
            while (!EOF)
            {
                balance += Convert.ToInt32(GetColumn("Balance"));
                SetColumn("Balance", balance);
                MoveNext();
            }

            return this.DataTable;
        }
        protected void AddOpActivityButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ExtraActivity activity;
                System.Collections.Specialized.ListDictionary l = new System.Collections.Specialized.ListDictionary();
                if (OpOnderwijsActiviteit.Checked)
                {
                    activity = new ExtraActivity(OpOndNaam.Text, OpOndAdres.Text, OpOndOmvang.Text, OpOndNiveau.SelectedText, OpOndAmbt.Text, OpOndStartDate.SelectedDate.GetValueOrDefault());
                    l.Add("motivatie", OpOndMotivatie.Text);
                    l.Add("type_activiteit_op", "Onderwijs");
                    _log.Debug("Onderwijs nevenactiviteit met motivatie {0}", OpOndMotivatie.Text);
                    EmptyTextBoxes(new List<RadTextBox>() { OpOndNaam, OpOndAdres, OpOndOmvang, OpOndAmbt,OpOndMotivatie});
                    OpOndStartDate.Clear();
                }
                else if (OpPolitiekActiviteit.Checked)
                {
                    activity = new ExtraActivity(OpPolOmschrijving.Text, OpPolAdres.Text, OpPolOmvang.Text, startDate: OpOndStartDate.SelectedDate.GetValueOrDefault() );
                    l.Add("motivatie", OpPolMotivatie.Text);
                    l.Add("type_activiteit_op", "Politiek");
                    _log.Debug("Politieke nevenactiviteit met motivatie {0}", OpPolMotivatie.Text);
                    EmptyTextBoxes(new List<RadTextBox>() { OpPolOmschrijving, OpPolAdres, OpPolOmvang,OpPolMotivatie});
                    OpPolStartDate.Clear();
                }
                else if (OpZelfstandigeActiviteit.Checked)
                {
                    activity = new ExtraActivity(OpZelfOmschrijving.Text, OpZelfAdres.Text, OpZelfOmvang.Text, startDate: OpZelfStartDate.SelectedDate.GetValueOrDefault());
                    l.Add("motivatie", OpZelfMotivatie.Text);
                    l.Add("type_activiteit_op", "Zelfstandig");
                    _log.Debug("Zelfstandige nevenactiviteit met motivatie {0}", OpZelfMotivatie);
                    EmptyTextBoxes(new List<RadTextBox>() { OpZelfOmschrijving, OpZelfAdres, OpZelfOmvang, OpZelfMotivatie });
                    OpZelfStartDate.Clear();
                }
                else
                {
                    activity = new ExtraActivity(OpAndOmschrijving.Text, OpAndAdres.Text, OpAndOmvang.Text, startDate: OpAndStartDate.SelectedDate.GetValueOrDefault());
                    l.Add("motivatie", OpMotivatie.Text);
                    l.Add("type_activiteit_op", "Anders");
                    _log.Debug("Andere nevenactiviteit met motivatie {0}", OpMotivatie.Text);
                    EmptyTextBoxes(new List<RadTextBox>() { OpAndOmschrijving, OpAndAdres, OpAndOmvang,OpMotivatie });
                    OpAndStartDate.Clear();
                }

                _log.Info("ExtraActivity created");
                if (Convert.ToDouble(assignementField.Text) > 70.00)
                {
                    _log.Info("Heeft goedkeuring van departementshoofd nodig");
                    activity.heeftDepGoedkeuringNodig = true;
                }

                l.Add("p_persoon", p_persoon);
                l.Add("omschrijving", activity.description);
                l.Add("locatie", activity.address);
                l.Add("type", "OP");
                l.Add("ambt", activity.function);
                l.Add("omvang", activity.amount);
                l.Add("startdatum", activity.startDate);
                l.Add("dep_goedkeuring_nodig", activity.heeftDepGoedkeuringNodig);
                l.Add("heeftNevenactiviteit", true);
                CumulatieDataContext cumul = new CumulatieDataContext();

                var code = cumul.KDGNEVENACTIVITEITEN_OpledingPerWogs.Where(p => p.OnderwijsGroepNaam.Equals(departmentField.Text)).First();

                l.Add("ow_groep", code.OnderwijsGroepCode);
                LinqDataSource1.Insert(l);
                _log.Debug("Nevenactiviteit voor OP toegevoegd");
                OpNevenActiviteit.Items[0].Enabled = false;
               }
        }
        public DataTable GetSOHByPrograms(int storeId, int programid, int month, int year)
        {
            var days = DateTime.DaysInMonth(year, month);
            var ld = new System.Collections.Specialized.ListDictionary();
            ld.Add("@storeid", storeId);
            ld.Add("@progID", programid);
            ld.Add("@month", month);
            ld.Add("@year", year);
            ld.Add("@days", days);
            this.LoadFromSql("SOHByPrograms", ld, CommandType.StoredProcedure);
            //TODO: filter out by commodity type here.

            return this.DataTable;
        }
        public MainForm(string[] args)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            OpenSource.UPnP.DText p = new OpenSource.UPnP.DText();
            p.ATTRMARK = "=";
            string[] filePaths = new string[1];

            foreach(string arg in args)
            {
                p[0] = arg;
                switch(p[1].ToUpper())
                {
                    case "-UDN":
                        MediaServerCore.CustomUDN = p[2];
                        break;
                    case "-CACHETIME":
                        MediaServerCore.CacheTime = int.Parse(p[2]);
                        break;
                    case "-INMPR":
                        MediaServerCore.INMPR = !(p[2].ToUpper()=="NO");
                        break;
                }
            }

            // Setup the UI
            transfersSplitter.Visible = viewTransfersPanelMenuItem.Checked;
            transfersListView.Visible = viewTransfersPanelMenuItem.Checked;

            try
            {
                serviceController = new ServiceController("UPnP Media Server");
                serviceStatus = serviceController.Status;
                OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"Service control mode...");
            }
            catch (System.InvalidOperationException)
            {
                serviceController = null;
                serviceStatus = ServiceControllerStatus.Stopped;
                OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"Stand alone mode...");
            }

            if (serviceController != null)
            {
                // Service controller mode
                serviceMenuItem.Visible = true;

                // Pause State
                pauseServerMenuItem.Visible = false;

                System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();
                channelProperties.Add("port", 12330);
                HttpChannel channel = new HttpChannel(channelProperties,
                    new SoapClientFormatterSinkProvider(),
                    new SoapServerFormatterSinkProvider());
                ChannelServices.RegisterChannel(channel, false);
                OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"RegisterChannel");

                if (serviceStatus == ServiceControllerStatus.Running)
                {
                    OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"RegisterWellKnownClientType");
                    RemotingConfiguration.RegisterWellKnownClientType(
                        typeof(UPnPMediaServer),
                        "http://localhost:12329/UPnPMediaServer/UPnPMediaServer.soap"
                        );
                    registeredServerType = true;
                }
            }
            else
            {
                // Stand alone mode
                if (registeredServerType == true || standAloneMode == true) return;

                standAloneMode = true;
                serviceMenuItem.Visible = false;

                // Stand alone mode
                mediaServerCore = new MediaServerCore("Media Server (" + System.Windows.Forms.SystemInformation.ComputerName + ")");
                this.mediaServerCore.OnDirectoriesChanged += new MediaServerCore.MediaServerCoreEventHandler(this.Sink_OnDirectoriesChanged);
                mediaServer = new UPnPMediaServer();

                // Pause State
                pauseServerMenuItem.Checked = this.mediaServerCore.IsPaused;
            }

            UpdateServiceUI();

            foreach(string arg in args)
            {
                p[0] = arg;
                switch(p[1].ToUpper())
                {
                    case "-P":
                        filePaths[0] = p[2];
                        try
                        {
                            this.AddDirs(filePaths);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        break;
                }
            }
        }
        public DataTable ConsumptionByUnit(int storeId, int year, int programID, BackgroundWorker bw)
        {
            // Dont Iterate
            DataTable dtbl = new DataTable();
            //if (programID == 0) //We don't filter by program ID.
            //{
            System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
            ld.Add("@storeid", storeId);
            ld.Add("@year", year);

            ////this.LoadFromSqlNoExec("SOH", ld);
            this.LoadFromSql("GetMonthlyConsumptionByUnits", ld, CommandType.StoredProcedure);
            return this.DataTable;
        }
        // GetParameters creates a list dictionary
        // consisting of a report parameter name and a value.
        private System.Collections.Specialized.ListDictionary GetParmeters(string parms)
        {
            System.Collections.Specialized.ListDictionary ld = new System.Collections.Specialized.ListDictionary();
            if (parms == null)
            {
                  return ld; // dictionary will be empty in this case
            }

            // parms are separated by &

            char[] breakChars = new char[] {'&'};
            string[] ps = parms.Split(breakChars);

            foreach (string p in ps)
            {
                  int iEq = p.IndexOf("=");
                  if (iEq > 0)
                  {
                        string name = p.Substring(0, iEq);
                        string val = p.Substring(iEq+1);
                        ld.Add(name, val);
                  }
            }
            return ld;
        }
        static void Main(string[] args)
        {
            Car car1 = new Car();
            car1.Make = "Oldsmobile";
            car1.Model = "Cutlas Supreme";

            Car car2 = new Car();
            car2.Make = "Geo";
            car2.Model = "Prism";

            Book book1 = new Book();
            book1.Author = "Robert Tabor";
            book1.Title = "Microsoft .NET XML Web Services";
            book1.ISBN = "0-000-00000-0";

            // ArrayLists are dynamically sized, and support other
            // cool features like sorting, removing items, etc.

            System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
            myArrayList.Add(car1);
            myArrayList.Add(car2);
            myArrayList.Add(book1);
            myArrayList.Remove(book1); // if not remove the book we get a error in foreach

            foreach (object o in myArrayList)
            {
                Console.WriteLine(((Car)o).Make);
            }

            Console.WriteLine("---------------------------------------------------------");

            // Dictionaries allow you to save a key along with
            // the value, and also support cool features.
            // There are different dictionaries to choose from ...

            System.Collections.Specialized.ListDictionary myDictionary
                = new System.Collections.Specialized.ListDictionary();
            myDictionary.Add(car1.Make, car1);
            myDictionary.Add(car2.Make, car2);
            myDictionary.Add(book1.Author, book1);

            // Easy access to an element using its key
            Console.WriteLine(((Car)myDictionary["Geo"]).Model);

            // But since its not strongly typed, we can easily break it
            // by adding a different type to the dictionary ...
            // Obviously, I'm trying to retrieve a book here, and then get its ... model?
            // Console.WriteLine(((Car)myDictionary["Robert Tabor"]).Model); <-- Error

            Console.WriteLine("---------------------------------------------------------");

            List<Car> myList = new List<Car>();
            myList.Add(car1);
            myList.Add(car2);
            // myList.Add(book1); <-- error

            foreach (Car car in myList)
            {
                Console.WriteLine(car.Model);
            }

            Console.WriteLine("---------------------------------------------------------");

            Dictionary<string, Car> myDictionary2 = new Dictionary<string, Car>();
            myDictionary2.Add(car1.Make, car1);
            myDictionary2.Add(car2.Make, car2);

            Console.WriteLine(myDictionary2["Geo"].Model);

            // instance values on initialization

            string[] names = { "Bob", "Steve", "Brian", "Chuck" };

            Car car3 = new Car() { Make = "Oldsmobile", Model = "Cutlas Supreme" };
            Car car4 = new Car() { Make = "Geo", Model = "Prism" };
            Car car5 = new Car() { Make = "Nissan", Model = "Altima" };

            List<Car> myList2 = new List<Car>() {
                new Car { Make = "Oldsmobile", Model = "Cutlas Supreme"},
                new Car { Make = "Geo", Model="Prism"},
                new Car { Make = "Nissan", Model = "Altima"}
            };

            Console.ReadLine();
        }