Пример #1
0
        public static bool LoadNewDeal(string sPath, string sStatus)
        {
            //Variables
            XmlDocument doc = new XmlDocument();

            doc.Load(sPath);
            XmlNodeList xmlJobs = doc.GetElementsByTagName("command");
            //Deal Import Variables
            string     sOrgName = "";
            string     sTitle   = "";
            string     sValue   = "";
            string     sRep     = "";
            string     sPerson  = "";
            string     sEmail   = "";
            DealStatus dsStatus = new DealStatus {
                Status = DealStatus.dealStatus.Open
            };

            if (xmlJobs.Count <= 0)
            {
                Console.WriteLine("ERROR:");
                Console.WriteLine("There are no Jobs in the specified XML file.");
                Console.ReadLine();
                return(true);
            }
            else
            {
                //Set the Deal Import Variables
                sOrgName = xmlJobs[0].SelectSingleNode("org_name").InnerText;
                sTitle   = xmlJobs[0].SelectSingleNode("title").InnerText;
                sValue   = xmlJobs[0].SelectSingleNode("value").InnerText;
                sRep     = xmlJobs[0].SelectSingleNode("rep").InnerText;
                sPerson  = xmlJobs[0].SelectSingleNode("client_name").InnerText;
                sEmail   = xmlJobs[0].SelectSingleNode("email").InnerText;

                //Load global Deal object with values from FileMaker import
                g_User          = new UserAPI(sRep);
                g_Deal.stage_id = g_User.GetStage();
                g_Deal.title    = sTitle;
                g_Deal.value    = sValue.Replace("$", "");
                //g_Deal.org_id = GetOrgID(sOrgName);
                if (sEmail.Contains(";"))
                {
                    sEmail = sEmail.Substring(0, sEmail.IndexOf(";"));
                }
                g_Deal.person_id = GetPersonID(sEmail);
                //Hard Coded values for the Deal
                g_Deal.add_time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                g_Deal.status   = dsStatus.StatusText;

                if (DealExists(sTitle))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }