Esempio n. 1
0
        static void CompleteTask(Network net, SimpleTask st, int Code, string Text)
        {
            SimpleTaskResult res = new SimpleTaskResult();

            res.ID        = st.ID;
            res.MachineID = SystemInfos.SysInfo.MachineID;
            res.Name      = st.Name;
            res.Result    = Code;
            res.Text      = Text;
            net.CompleteSimpleTask(res);
        }
Esempio n. 2
0
        void ReportThings(SQLLib sql, string MachineID, string Method, SimpleTaskResult ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot)
        {
            string ID = MachineID + "\\" + Method;

            bool ReportToAdmin   = RepElementRoot.ReportToAdmin.Value;
            bool ReportToClient  = RepElementRoot.ReportToClient.Value;
            bool UrgentForAdmin  = RepElementRoot.UrgentForAdmin.Value;
            bool UrgentForClient = RepElementRoot.UrgentForClient.Value;

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0)
                {
                    ReportToAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0)
                {
                    ReportToClient = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0)
                {
                    UrgentForAdmin = false;
                }
                if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0)
                {
                    UrgentForClient = false;
                }
            }

            if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false)
            {
                return;
            }
            ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) |
                                   (ReportToClient == true ? ReportingFlags.ReportToClient : 0) |
                                   (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) |
                                   (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0);

            ReportingProcessor.ReportSimpleTaskCompletion(sql, MachineID, Method, ar, Flags);

            if (AlreadyReported.ContainsKey(ID) == true)
            {
                AlreadyReported[ID] |= (Int64)Flags;
            }
            else
            {
                AlreadyReported.Add(ID, (Int64)Flags);
            }
        }
Esempio n. 3
0
        public RESTStatus CompleteSTask(SQLLib sql, SimpleTaskResult STaskResult, NetworkConnectionInfo ni)
        {
            if (ni.HasAcl(ACLFlags.ComputerLogin) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            if (STaskResult == null)
            {
                ni.Error   = "Invalid ID";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.NotFound);
            }

            lock (ni.sqllock)
            {
                STaskResult.MachineID = ni.Username;
                if (STaskExsits(sql, STaskResult.ID, STaskResult.MachineID) == false)
                {
                    ni.Error   = "Invalid ID";
                    ni.ErrorID = ErrorFlags.InvalidData;
                    return(RESTStatus.NotFound);
                }
            }

            lock (ni.sqllock)
            {
                STaskResult.Name = Convert.ToString(sql.ExecSQLScalar("SELECT Name FROM SimpleTasks WHERE ID=@id",
                                                                      new SQLParam("@id", STaskResult.ID)));
            }

            lock (ni.sqllock)
            {
                sql.ExecSQL("DELETE FROM SimpleTasks WHERE ID=@id",
                            new SQLParam("@id", STaskResult.ID));
            }

            Thread t = new Thread(new ParameterizedThreadStart(new DReportingThread(ReportingThread)));

            t.Start(STaskResult);

            return(RESTStatus.Success);
        }
Esempio n. 4
0
        /// <summary>
        /// 执行业务逻辑区
        /// </summary>
        public override void ExecuteTask()
        {
            this.Results = null;
            if (this.input == null)
            {
                return;
            }

            string txtvalue = this.input as string;
            //声明显示的结果
            string heading = string.Format("The time on the server is {0}", DateTime.Now.ToShortDateString());
            string detail  = string.Format("The value in the Textbox  is:{0}", txtvalue);
            //把结果保存成一个SimpleTaskResult对象
            SimpleTaskResult str = new SimpleTaskResult(heading, detail);

            this.Results = str;
            // throw new NotImplementedException();
        }
Esempio n. 5
0
    public string Identify(NameValueCollection queryString)
    {
        string xString = queryString["minx"];
        string yString = queryString["miny"];
        string locXString = "";
        string locYString = "";
        int x = Convert.ToInt32(xString);
        int y = Convert.ToInt32(yString);
        IGISResource resource;
        IQueryFunctionality query;
        ESRI.ArcGIS.ADF.Web.Geometry.Point mapPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(x, y,
            m_map.GetTransformationParams(TransformationDirection.ToMap));
        List<DataSet> gdsList = new List<DataSet>();
        foreach (IMapFunctionality mapFunc in m_map.GetFunctionalities())

        {
            if (mapFunc is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality) continue;
            resource = mapFunc.Resource;
            query = resource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), "identify_") as IQueryFunctionality;

            string[] layerIds;
            string[] layerNames;
            query.GetQueryableLayers(null, out layerIds, out layerNames);
            string resourceType = resource.DataSource.GetType().ToString();
            double roundFactor = Math.Pow(10, m_numberDecimals);
            string pointXString = Convert.ToString(Math.Round(mapPoint.X * roundFactor) / roundFactor);
            string pointYString = Convert.ToString(Math.Round(mapPoint.Y * roundFactor) / roundFactor);
            locXString = pointXString;
            locYString = pointYString;
            DataTable[] ds = null;
            try
            {
                ds = query.Identify(mapFunc.Name, mapPoint, m_IdentifyTolerance, m_idOption, null);
            }
            catch (Exception e)
            {
                DataTable table = new DataTable();
                table.TableName = "Identify Error: " + e.Message;
                ds = new DataTable[] { table };
            }
            if (ds != null && ds.Length > 0)
            {
                DataSet gds = new DataSet();
                DataTable table;
                for (int j=ds.Length-1; j>=0;j--)
                {
                    table = ds[j];
                    // Remove empty tables.
                    if (table.Rows.Count == 0 && table.TableName.IndexOf("Error") < 0)
                        continue;
                    GraphicsLayer layer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(table, System.Drawing.Color.Empty, System.Drawing.Color.Aqua);
                    if (layer != null)
                        gds.Tables.Add(layer);
                    else
                        gds.Tables.Add(table);
                }
                if (gds.Tables.Count == 0)
                    continue;

                gds.DataSetName = resource.Name + " (" + pointXString + ", " + pointYString + ")";
                gdsList.Add(gds);
            }
        }

        for (int i = gdsList.Count-1; i >=0; i--)
        {
            m_resultsDisplay.DisplayResults(null, null, null, gdsList[i]);
        }
        if (gdsList.Count == 0)
        {
            string heading = "Location (" + locXString + ", " + locYString + ") No results found";
            string detail = "No results found";
            SimpleTaskResult str = new SimpleTaskResult(heading, detail);
            m_resultsDisplay.DisplayResults(null, null, null, str);
        }
        return m_resultsDisplay.CallbackResults.ToString();
    }
Esempio n. 6
0
        void ReportingThread(object SimpleTaskO)
        {
            try
            {
                using (SQLLib sql = SQLTest.ConnectSQL("Fox SDC Server for SimpleTask Result Data"))
                {
                    if (sql == null)
                    {
                        FoxEventLog.WriteEventLog("Cannot connect to SQL Server for SimpleTask Result Reporting!", System.Diagnostics.EventLogEntryType.Error);
                        return;
                    }
                    SimpleTaskResult SimpleTask = (SimpleTaskResult)SimpleTaskO;

                    List <PolicyObject>        Pol             = Policies.GetPolicyForComputerInternal(sql, SimpleTask.MachineID);
                    Dictionary <string, Int64> AlreadyReported = new Dictionary <string, long>();
                    foreach (PolicyObject PolO in Pol)
                    {
                        if (PolO.Type != PolicyIDs.ReportingPolicy)
                        {
                            continue;
                        }
                        ReportingPolicyElement RepElementRoot = JsonConvert.DeserializeObject <ReportingPolicyElement>(Policies.GetPolicy(sql, PolO.ID).Data);
                        if (RepElementRoot.Type != ReportingPolicyType.SimpleTaskCompleted)
                        {
                            continue;
                        }
                        if (RepElementRoot.ReportToAdmin == null)
                        {
                            RepElementRoot.ReportToAdmin = false;
                        }
                        if (RepElementRoot.ReportToClient == null)
                        {
                            RepElementRoot.ReportToClient = false;
                        }
                        if (RepElementRoot.UrgentForAdmin == null)
                        {
                            RepElementRoot.UrgentForAdmin = false;
                        }
                        if (RepElementRoot.UrgentForClient == null)
                        {
                            RepElementRoot.UrgentForClient = false;
                        }
                        if (RepElementRoot.ReportToAdmin == false && RepElementRoot.ReportToClient == false && RepElementRoot.UrgentForAdmin == false &&
                            RepElementRoot.UrgentForClient == false)
                        {
                            continue;
                        }

                        foreach (string Element in RepElementRoot.ReportingElements)
                        {
                            ReportingPolicyElementSimpleTaskCompleted arprep = JsonConvert.DeserializeObject <ReportingPolicyElementSimpleTaskCompleted>(Element);

                            ReportThings(sql, SimpleTask.MachineID, "Completed", SimpleTask, ref AlreadyReported, RepElementRoot);
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                FoxEventLog.WriteEventLog("SEH in SimpleTask Result Reporting " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
            }
        }
Esempio n. 7
0
        public static void ReportSimpleTaskCompletion(SQLLib sql, string MachineID, string Method, SimpleTaskResult AR, ReportingFlags Flags)
        {
            Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported);

            ReportingSimpleTaskCompletion a = new  ReportingSimpleTaskCompletion();

            a.Action = Method;
            a.App    = AR;

            sql.InsertMultiData("Reporting",
                                new SQLData("MachineID", MachineID),
                                new SQLData("Type", ReportingPolicyType.SimpleTaskCompleted),
                                new SQLData("Data", JsonConvert.SerializeObject(a)),
                                new SQLData("Flags", Flags));
        }