コード例 #1
0
        public static bool HandleServerLogin(ACA.LabelX.Toolbox.LogonInfo info, out string updateNodig)
        {
            updateNodig = String.Empty;

            GlobalDataStore.Logger.Debug(info.MachineName + ".HandleServerLoging");
            //The received data should be saved to the right place...
            if (Authenticate(info.MachineName, info.Username, info.Password) == false)
            {
                return(false);
            }
            string AppPath  = GlobalDataStore.AppPath;
            string confPath = AppPath + @"\ACALabelXServer.config.xml";

            lock (GlobalDataStore.LockClass)
            {
                XmlDocument theDoc = new XmlDocument();
                if (!File.Exists(confPath))
                {
                    return(false);
                }
                theDoc.Load(confPath);
                XmlNode node0 = theDoc.SelectSingleNode("/configuration/general-settings/allowed_versions");
                if (node0 == null)
                {
                    return(false);
                }
                Double minVersion = Double.Parse(node0.Attributes["begin"].Value, CultureInfo.InvariantCulture);
                Double maxVersion = Double.Parse(node0.Attributes["end"].Value, CultureInfo.InvariantCulture);

                if ((minVersion > info.ProgramVersion) || (maxVersion < info.ProgramVersion))
                {
                    return(false);
                }

                XmlNode node3 = theDoc.SelectSingleNode("/configuration/general-settings/beginUpdate");
                if (node3 != null)
                {
                    Double updateVersion = Double.Parse(node3.Attributes["version"].Value, CultureInfo.InvariantCulture);
                    if (info.ProgramVersion < updateVersion)
                    {
                        updateNodig = node3.Attributes["executable"].Value;
                        GlobalDataStore.Logger.Warning("Sending Update notice to client");
                    }
                }

                XmlNode node4          = theDoc.SelectSingleNode("/configuration/general-settings/folders/SettingsRootFolder");
                string  settingsFolder = node4.InnerText;
                if (!settingsFolder.EndsWith("\\"))
                {
                    settingsFolder += "\\";
                }
                createClientXML(info, settingsFolder + "Clients.xml");

                theDoc.Save(confPath); //Is this really needed? JBOS 19-04-2013
            }
            return(true);
        }
コード例 #2
0
        public bool Login(ACA.LabelX.Toolbox.LogonInfo info, out string updateNodig)
        {
            GlobalDataStore.Logger.Debug(info.MachineName + ".Login");
            if (!ClientList.ContainsKey(info.MachineName))
            {
                ClientList.Add(info.MachineName, new ClientMachine(info.MachineName, info.IpNumber.ToString(), info.ProgramVersion));
            }
            bool bRet = RemoteObjectHelper.HandleServerLogin(info, out updateNodig);

            return(bRet);
        }
コード例 #3
0
        public bool Login(out string updateNodig)
        {
            updateNodig = "";
            bool   bRet;
            string HostName = System.Net.Dns.GetHostName();
            RemClientControlObject helper = new ACA.LabelX.Client.RemClientControlObject();
            string mach;

            LogonInfo theInfo = new ACA.LabelX.Toolbox.LogonInfo();

            //{
            //    MachineDescription = Environment.MachineName,
            //    Username = "******",
            //    Password = "******",
            //    ProgramVersion = GlobalDataStore.ProgramVersion,
            //    updateReady = checkUpdate(),
            //    IpNumber = System.Net.Dns.GetHostEntry(HostName).AddressList[0],
            //    PrintGroups = helper.GetLabelPrintGroupsEx(out mach),
            //    MachineName = mach
            //};
            theInfo.MachineDescription = Environment.MachineName;
            theInfo.Username           = "******";
            theInfo.Password           = "******";
            theInfo.ProgramVersion     = GlobalDataStore.ProgramVersion;
            theInfo.updateReady        = checkUpdate();

            System.Net.IPHostEntry IpHostEntry = System.Net.Dns.GetHostEntry(HostName);
            System.Net.IPAddress[] IpArray     = IpHostEntry.AddressList;
            foreach (System.Net.IPAddress IPAddress in IpArray)
            {
                if (!IPAddress.IsIPv6LinkLocal)
                {
                    theInfo.IpNumber = IPAddress;
                }
            }

            theInfo.PrintGroups = helper.GetLabelPrintGroupsEx(out mach);
            theInfo.MachineName = mach;

            RemoteObject obj = GetRemoteObject();

            try
            {
                bRet = obj.Login(theInfo, out updateNodig);
            }
            catch (Exception)
            {
                bRet = false;
            }
            return(bRet);
        }
コード例 #4
0
        private static void createClientXML(ACA.LabelX.Toolbox.LogonInfo info, string confPath)
        {
            XmlDocument theDoc = new XmlDocument();
            XmlNode     rootNode;

            if (File.Exists(confPath))
            {
                try
                {
                    theDoc.Load(confPath);
                    rootNode = theDoc.SelectSingleNode("/clients");
                }
                catch
                {
                    //clients.xml damaged, recreate clients.xml
                    XmlDeclaration xmlDeclaration = theDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                    // Create the root element
                    rootNode = theDoc.CreateElement("clients");
                    theDoc.InsertBefore(xmlDeclaration, theDoc.DocumentElement);
                    theDoc.AppendChild(rootNode);
                }
            }
            else
            {
                XmlDeclaration xmlDeclaration = theDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                // Create the root element
                rootNode = theDoc.CreateElement("clients");
                theDoc.InsertBefore(xmlDeclaration, theDoc.DocumentElement);
                theDoc.AppendChild(rootNode);
            }

            string      xpath = "/clients/machine[@name='" + info.MachineName + "']";
            XmlNodeList lst   = theDoc.SelectNodes(xpath);
            XmlNode     node2;

            if (lst == null)
            {
                node2 = null;
            }
            else
            {
                node2 = lst.Count > 0 ? lst[0] : null;
            }
            //XmlNode node2 = theDoc.SelectSingleNode(xpath);
            if (node2 != null)
            {
                foreach (XmlNode chld in node2.ChildNodes)
                {
                    node2.RemoveChild(chld);
                }
                node2.Attributes["externalip"].Value     = ((CallContext.GetData("ClientIP"))).ToString();
                node2.Attributes["internalip"].Value     = info.IpNumber.ToString();
                node2.Attributes["description"].Value    = info.MachineDescription;
                node2.Attributes["lastseen"].Value       = DateTime.Now.ToString("o");
                node2.Attributes["version"].Value        = info.ProgramVersion.ToString(CultureInfo.InvariantCulture);
                node2.Attributes["readyForUpdate"].Value = info.updateReady.ToString();
            }
            else
            {
                XmlElement el = theDoc.CreateElement("machine");
                el.SetAttribute("name", info.MachineName);
                el.SetAttribute("externalip", (CallContext.GetData("ClientIP")).ToString());
                el.SetAttribute("internalip", info.IpNumber.ToString());
                el.SetAttribute("description", info.MachineDescription);
                el.SetAttribute("firstseen", DateTime.Now.ToString("o"));
                el.SetAttribute("lastseen", DateTime.Now.ToString("o"));
                el.SetAttribute("version", info.ProgramVersion.ToString(CultureInfo.InvariantCulture));
                el.SetAttribute("readyForUpdate", info.updateReady.ToString());
                node2 = rootNode.AppendChild(el);
            }
            XmlElement pgsnode = theDoc.CreateElement("printgroups");

            foreach (PrintGroupItem o in info.PrintGroups)
            {
                XmlElement gnode = theDoc.CreateElement("printgroup");
                gnode.SetAttribute("name", o.Name);
                pgsnode.AppendChild(gnode);
            }
            node2.AppendChild(pgsnode);
            theDoc.Save(confPath);
        }