예제 #1
0
        public ActionResult <string> add(dynamic param)
        {
            var       jsonParams = JsonConvert.DeserializeObject <dynamic>(param.ToString());
            TaskOrder obj        = new TaskOrder
            {
                TaskOrderOid = Guid.NewGuid().ToString("D"),
                Taskid       = jsonParams.Taskid,
                Tasktitle    = jsonParams.Tasktitle,
                Tasktype     = jsonParams.Tasktype,
                Taskstatus   = jsonParams.Taskstatus,

                Taskobjectname = jsonParams.Taskobjectname,
                TaskTownStreet = jsonParams.TaskTownStreet,
                TaskCommunity  = jsonParams.TaskCommunity,

                AlarmStationnumber = jsonParams.AlarmStationnumber,
                AlarmStationname   = jsonParams.AlarmStationname,
                Alarmcontent       = jsonParams.Alarmcontent,
                Alarmfactor        = jsonParams.Alarmfactor,
                Alarmtime          = jsonParams.Alarmtime,

                Contributionrate        = jsonParams.Contributionrate,
                Contributionrateranking = jsonParams.Contributionrateranking,

                Collector         = "-",
                Collectorphone    = "-",
                Taskfeedbacktimes = 0,

                Taskcontent        = jsonParams.Taskcontent,
                Tasknotes          = jsonParams.Tasknotes,
                Taskfallback       = 0,
                Taskfallbackreason = "",

                Checktime            = jsonParams.Checktime,
                Taskfallbacktime     = jsonParams.Taskfallbacktime,
                Taskdeadline         = jsonParams.Taskdeadline,
                Taskfeedbacktime     = jsonParams.Taskfeedbacktime,
                Taskcompletetime     = jsonParams.Taskcompletetime,
                Taskstatusupdatetime = DateTime.Now,
                Taskreceivingtime    = DateTime.Now
            };

            _context.Add(obj);
            int result = _context.SaveChanges();
            var data   = new { TaskOrderOid = obj.TaskOrderOid, result = result };

            return(common.transResult(data));
        }
예제 #2
0
        public ActionResult <string> add(dynamic param)
        {
            var    jsonParams = JsonConvert.DeserializeObject <dynamic>(param.ToString());
            string oid        = Convert.ToString(jsonParams.Taskoid);
            string id         = Convert.ToString(jsonParams.Taskid);
            int    times      = getTimes_Feedback(Convert.ToString(jsonParams.Taskoid));

            // 查询任务信息
            string sql   = "TaskOrderOid = @0 and Taskid = @1 And Taskstatus != @2 And Taskstatus != @3";
            var    query = _context.TaskOrder
                           .AsQueryable()
                           .Where(sql, oid, id, "已回退", "已完成");
            string resOid = "";
            int    result = 0;

            if (query.Count() == 1)
            {
                TaskOrder    oder = query.Take(1).Single();
                TaskFeedback obj  = new TaskFeedback
                {
                    TaskFeedbackOid           = Guid.NewGuid().ToString("D"),
                    Taskordeid                = jsonParams.Taskoid,
                    Taskid                    = jsonParams.Taskid,
                    Supervision               = jsonParams.Supervision,
                    Isitnecessarytorectify    = jsonParams.Isitnecessarytorectify,
                    Islawenforcementnecessary = jsonParams.Islawenforcementnecessary,
                    Isitnecessarytopunish     = jsonParams.Isitnecessarytopunish,
                    Picturenames              = jsonParams.Picturenames,

                    Taskfeedbackperson      = jsonParams.Taskfeedbackperson,
                    Taskfeedbackpersonphone = jsonParams.Taskfeedbackpersonphone,
                    Taskfeedbacktimes       = times,
                    Taskfeedbacktime        = DateTime.Now,

                    Tasktype       = oder.Tasktype,
                    Taskstatus     = "开展中",
                    TaskTypeSrc    = oder.TaskTypeSrc,
                    TaskTypesubSrc = oder.TaskTypesubSrc
                };
                UserInfo usr = common.getUserInfo(jsonParams.userName);
                if (usr != null)
                {
                    obj.TaskfeedbackpersonId    = usr.Useroid;
                    obj.Taskfeedbackperson      = usr.Username;
                    obj.Taskfeedbackpersonphone = usr.Userphone;
                }
                _context.Add(obj);
                result = _context.SaveChanges();
                if (result == 1)
                {
                    result = updateTimes_Feedback(Convert.ToString(jsonParams.Taskoid));
                }
                resOid = obj.TaskFeedbackOid;
            }
            var data = new { TaskFeedbackOid = resOid, result = result };

            return(common.transResult(data));
        }
예제 #3
0
        public ActionResult <string> add(dynamic param)
        {
            var      jsonParams = JsonConvert.DeserializeObject <dynamic>(param.ToString());
            int      id         = jsonParams.DeployId == null ? 0 : Convert.ToInt32(jsonParams.DeployId);
            DateTime dtTime     = common.checkTime(jsonParams.Alarmtime);

            //if (!_context.Infoalarm.Any())
            Infoalarm obj = new Infoalarm {
                InfoalarmOid = Guid.NewGuid().ToString("D"), DeployId = id, AlarmType = jsonParams.AlarmType, Alarmindex = jsonParams.Alarmindex, Alarmlevel = jsonParams.Alarmlevel, Alarmcontent = jsonParams.Alarmcontent, Alarmtime = dtTime, Cratetime = DateTime.Now
            };

            _context.Add(obj);
            int result = _context.SaveChanges();
            var data   = new { InfoalarmOid = obj.InfoalarmOid, result = result };

            return(common.transResult(data));
        }
예제 #4
0
        public void JobInfo_Group()
        {
            // 读取文件夹列表
            if (common.coon == "")
            {
                return;
            }
            var provider = new PhysicalFileProvider(Directory.GetCurrentDirectory() + @"/ftpData/task");
            var contents = provider.GetDirectoryContents(string.Empty);

            foreach (var item in contents)
            {
                if (!item.Name.Contains("group_"))
                {
                    continue;
                }
                if (item.IsDirectory == false)
                {
                    int           result = 0;
                    List <string> errs   = new List <string>();
                    using (System.IO.StreamReader file = System.IO.File.OpenText(item.PhysicalPath))
                    {
                        Console.WriteLine("new file group:: " + item.PhysicalPath);
                        using (JsonTextReader reader = new JsonTextReader(file))
                        {
                            // 循环解析文件json数据
                            JObject jsonObject = (JObject)JToken.ReadFrom(reader);
                            JArray  jsonValues = (JArray)jsonObject["RECORDS"];
                            if (jsonValues.Count > 0)
                            {
                                //按逻辑结构组织对象
                                //for (int i = 0; i < jsonValues.Count; i++)
                                //{
                                //    dictObjs[jsonValues[i]["id"].ToString()] = (JObject)jsonValues[i];
                                //}
                                //
                                //按逻辑结构组织对象
                                //Dictionary<string, JObject> dictOrg = new Dictionary<string, JObject>();
                                //for (int i = 0; i < jsonValues.Count; i++)
                                //{
                                //    JObject obj = (JObject)jsonValues[i];
                                //}dictObjs

                                var optionsBuilder = new DbContextOptionsBuilder <db_MicroStationContext>();
                                using (var context = new db_MicroStationContext(optionsBuilder.Options))
                                {
                                    var queryAll = context.Organization.AsQueryable().Where("OrganizationOid != @0", "").ToList();
                                    foreach (var value in jsonValues)
                                    {
                                        string Nodepath = (string)value["path"];
                                        if (Nodepath == null || !Nodepath.Contains("东莞市生态环境局"))
                                        {
                                            continue;
                                        }

                                        string srcOid = (string)value["id"];
                                        Console.WriteLine("srcOid:: " + srcOid);
                                        var query = queryAll.Where(s => s.OrganizationOid == srcOid).FirstOrDefault();
                                        try
                                        {
                                            if (query == null)
                                            {
                                                Organization obj = new Organization
                                                {
                                                    OrganizationOid      = srcOid,
                                                    Organizationcategory = (int)value["category"],
                                                    Departmenttype       = (int)value["departmentType"],
                                                    Groupname            = (string)value["groupName"],
                                                    GroupType            = (int)value["groupType"],
                                                    Organizationcode     = (string)value["orgCode"],
                                                    Organizationlevel    = (int)value["orgLevel"],
                                                    Parentnodecode       = (string)value["parentId"],
                                                    Nodepath             = (string)value["path"],
                                                };
                                                context.Add(obj);
                                            }
                                            else
                                            {
                                                query.OrganizationOid      = srcOid;
                                                query.Organizationcategory = (int)value["category"];
                                                query.Departmenttype       = (int)value["departmentType"];
                                                query.Groupname            = (string)value["groupName"];
                                                query.GroupType            = (int)value["groupType"];
                                                query.Organizationcode     = (string)value["orgCode"];
                                                query.Organizationlevel    = (int)value["orgLevel"];
                                                query.Parentnodecode       = (string)value["parentId"];
                                                query.Nodepath             = (string)value["path"];
                                            }
                                            dictGroups[srcOid] = (JObject)value;
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("err srcID::" + srcOid);
                                            errs.Add((string)value["id"]);
                                            throw;
                                        }
                                    }
                                    result = context.SaveChanges();
                                    Console.WriteLine("res count::" + result.ToString());

                                    // 记录操作
                                    TaskDocking docking = new TaskDocking
                                    {
                                        TaskDockingOid = Guid.NewGuid().ToString("D"),
                                        Filename       = item.Name,
                                        Filepath       = item.PhysicalPath,
                                        Dockingtype    = "组织机构",
                                        AssociationId  = "",
                                        Dockingmode    = "download",
                                        Dockingtime    = DateTime.Now,
                                        Dockingresults = errs.Count > 0 ? "失败" : "完成",
                                        Dockingtimes   = 1,
                                        Dockmark       = errs.ToString(),
                                        Createtime     = DateTime.Now
                                    };
                                    context.Add(docking);
                                    int result2 = context.SaveChanges();
                                }
                            }
                        }
                    }

                    // 转移文件
                    if (result > errs.Count)
                    {
                        //File.Copy(item.PhysicalPath, AppContext.BaseDirectory + @"ftpData/user_old/" + item.Name);
                        //File.Delete(item.PhysicalPath);
                    }
                }
            }
        }
예제 #5
0
        public void JobInfo_User()
        {
            // 读取文件夹列表
            if (common.coon == "")
            {
                return;
            }
            var provider = new PhysicalFileProvider(Directory.GetCurrentDirectory() + @"/ftpData/task");
            var contents = provider.GetDirectoryContents(string.Empty);

            foreach (var item in contents)
            {
                if (!item.Name.Contains("user_"))
                {
                    continue;
                }
                if (item.Name.Contains("user_group"))
                {
                    continue;
                }
                if (item.IsDirectory == false)
                {
                    int           result = 0;
                    List <string> errs   = new List <string>();
                    using (System.IO.StreamReader file = System.IO.File.OpenText(item.PhysicalPath))
                    {
                        Console.WriteLine("new file user: "******"RECORDS"];
                            if (jsonValues.Count > 0)
                            {
                                var optionsBuilder = new DbContextOptionsBuilder <db_MicroStationContext>();
                                using (var context = new db_MicroStationContext(optionsBuilder.Options))
                                {
                                    var queryAll = context.UserInfo.AsQueryable().Where("Useroid != @0", "").ToList();
                                    foreach (var value in jsonValues)
                                    {
                                        //提取suer的group信息
                                        string userId = (string)value["id"];
                                        Console.WriteLine("userId:: " + userId);
                                        if (!dictUsrGroups.ContainsKey(userId))
                                        {
                                            continue;
                                        }

                                        var query = queryAll.Where(s => s.Useroid == userId).FirstOrDefault();
                                        try
                                        {
                                            JObject objGroup = dictGroups[dictUsrGroups[userId]];
                                            if (query == null)
                                            {
                                                UserInfo obj = new UserInfo
                                                {
                                                    UserInfoOid     = Guid.NewGuid().ToString("D"),
                                                    Useroid         = (string)value["id"],
                                                    Userid          = (string)value["userName"],
                                                    Username        = (string)value["displayName"],
                                                    UserPwd         = "On8U4+dy1Rs=", //默认密码12345678
                                                    Userphone       = (string)value["mobile"],
                                                    Isitavailable   = (ulong)value["enable"],
                                                    Organizationoid = dictUsrGroups[userId],
                                                    Groupname       = (string)objGroup["groupName"],
                                                    Nodepath        = (string)objGroup["path"],
                                                };
                                                checkPermission(ref obj);
                                                context.Add(obj);
                                            }
                                            else
                                            {
                                                query.Useroid         = (string)value["id"];
                                                query.Userid          = (string)value["userName"];
                                                query.Username        = (string)value["displayName"];
                                                query.Userphone       = (string)value["mobile"];
                                                query.Isitavailable   = (ulong)value["enable"];
                                                query.Organizationoid = dictUsrGroups[userId];
                                                query.Groupname       = (string)objGroup["groupName"];
                                                query.Nodepath        = (string)objGroup["path"];
                                                checkPermission(ref query);
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("err srcID::" + userId);
                                            errs.Add((string)value["id"]);
                                            throw;
                                        }
                                    }
                                    result = context.SaveChanges();
                                    Console.WriteLine("res count::" + result.ToString());

                                    // 记录操作
                                    TaskDocking docking = new TaskDocking
                                    {
                                        TaskDockingOid = Guid.NewGuid().ToString("D"),
                                        Filename       = item.Name,
                                        Filepath       = item.PhysicalPath,
                                        Dockingtype    = "用户信息",
                                        AssociationId  = "",
                                        Dockingmode    = "download",
                                        Dockingtime    = DateTime.Now,
                                        Dockingresults = errs.Count > 0 ? "失败" : "完成",
                                        Dockingtimes   = 1,
                                        Dockmark       = errs.ToString(),
                                        Createtime     = DateTime.Now
                                    };
                                    context.Add(docking);
                                    int result2 = context.SaveChanges();
                                }
                            }
                        }
                    }

                    // 转移文件
                    Thread.Sleep(1000);
                    if (result > errs.Count || errs.Count == 0)
                    {
                        File.Copy(item.PhysicalPath, Directory.GetCurrentDirectory() + @"/ftpData/task_old/" + item.Name);
                        File.Copy(item.PhysicalPath.Replace("user_", "user_group"), Directory.GetCurrentDirectory() + @"/ftpData/task_old/" + item.Name.Replace("user_", "user_group"));
                        File.Copy(item.PhysicalPath.Replace("user_", "group_"), Directory.GetCurrentDirectory() + @"/ftpData/task_old/" + item.Name.Replace("user_", "group_"));
                        Thread.Sleep(2000);
                        File.Delete(item.PhysicalPath);
                        File.Delete(item.PhysicalPath.Replace("user_", "user_group"));
                        File.Delete(item.PhysicalPath.Replace("user_", "group_"));
                        common.userManger.Init();       // 用户信息重载
                    }
                }
            }
        }
예제 #6
0
        public void StartJob()
        {
            // 读取文件夹列表
            if (common.coon == "")
            {
                return;
            }
            var provider = new PhysicalFileProvider(Directory.GetCurrentDirectory() + @"/ftpData/alarm");
            var contents = provider.GetDirectoryContents(string.Empty);

            foreach (var item in contents)
            {
                if (item.IsDirectory == false)
                {
                    int           result = 0;
                    List <string> errs   = new List <string>();
                    using (System.IO.StreamReader file = System.IO.File.OpenText(item.PhysicalPath))
                    {
                        Console.WriteLine("new file alarm:: " + item.PhysicalPath);
                        using (JsonTextReader reader = new JsonTextReader(file))
                        {
                            // 循环解析文件json数据
                            JObject jsonObject = (JObject)JToken.ReadFrom(reader);
                            JArray  jsonValues = (JArray)jsonObject["RECORDS"];
                            if (jsonValues.Count > 0)
                            {
                                var optionsBuilder = new DbContextOptionsBuilder <db_MicroStationContext>();
                                optionsBuilder.UseMySql(common.coon);
                                using (var context = new db_MicroStationContext(optionsBuilder.Options))
                                {
                                    var queryAll = context.Infoalarm.AsQueryable().Where("srcOID != @0", "").OrderByDescending(d => d.Alarmtime).Take(1000).ToList();
                                    foreach (var value in jsonValues)
                                    {
                                        string srcOid = (string)value["id"];
                                        Console.WriteLine("srcOid:: " + srcOid);
                                        var query = queryAll.Where(s => s.SrcOid == srcOid).FirstOrDefault();
                                        if (query != null)
                                        {
                                            continue;
                                        }
                                        try
                                        {
                                            Infoalarm obj = new Infoalarm
                                            {
                                                InfoalarmOid = Guid.NewGuid().ToString("D"),
                                                DeployId     = (int)value["targetId"],
                                                SrcOid       = (string)value["id"],
                                                AlarmType    = (string)value["targetType"] == "station" ? "监测站点实时告警" : "",
                                                Alarmindex   = (string)value["warningIndicator"],
                                                Alarmlevel   = (string)value["warningLevel"],
                                                Alarmtitle   = (string)value["warningTitle"],
                                                Alarmcontent = (string)value["warningContent"],
                                                Alarmtime    = (DateTime)value["createTime"],
                                                Datatime     = (DateTime)value["lastTime"],
                                                Cratetime    = DateTime.Now
                                            };
                                            if (!string.IsNullOrEmpty((string)value["normalTime"]))
                                            {
                                                obj.AlarmtimeNormal = (DateTime)value["normalTime"];
                                            }
                                            if (!string.IsNullOrEmpty((string)value["lastTime"]))
                                            {
                                                obj.AlarmtimeLast = (DateTime)value["lastTime"];
                                            }
                                            context.Add(obj);
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("err srcID::" + srcOid);
                                            errs.Add((string)value["id"]);
                                            throw;
                                        }
                                    }
                                    result = context.SaveChanges();
                                    Console.WriteLine("res count::" + result.ToString());

                                    // 记录操作
                                    TaskDocking docking = new TaskDocking
                                    {
                                        TaskDockingOid = Guid.NewGuid().ToString("D"),
                                        Filename       = item.Name,
                                        Filepath       = item.PhysicalPath,
                                        Dockingtype    = "站点告警",
                                        AssociationId  = "",
                                        Dockingmode    = "download",
                                        Dockingtime    = DateTime.Now,
                                        Dockingresults = errs.Count > 0 ? "失败" : "完成",
                                        Dockingtimes   = 1,
                                        Dockmark       = errs.ToString(),
                                        Createtime     = DateTime.Now
                                    };
                                    context.Add(docking);
                                    int result2 = context.SaveChanges();
                                }
                            }
                            Task.Run(() =>
                            {
                            });
                        }
                    }

                    // 转移文件
                    if (result > errs.Count || errs.Count == 0)
                    {
                        File.Copy(item.PhysicalPath, Directory.GetCurrentDirectory() + @"/ftpData/alarm_old/" + item.Name);
                        Thread.Sleep(1000);
                        File.Delete(item.PhysicalPath);
                    }
                }
            }
        }
예제 #7
0
        public void DoDowndata_Task()
        {
            // 读取文件夹列表
            if (common.coon == "")
            {
                return;
            }
            var provider = new PhysicalFileProvider(Directory.GetCurrentDirectory() + @"/ftpData/task");

            Console.WriteLine(Directory.GetCurrentDirectory() + @"/ftpData/task");
            var contents = provider.GetDirectoryContents(string.Empty);

            foreach (var item in contents)
            {
                if (item.IsDirectory == false)
                {
                    int           result = 0;
                    List <string> errs   = new List <string>();
                    using (System.IO.StreamReader file = System.IO.File.OpenText(item.PhysicalPath))
                    {
                        Console.WriteLine("new file task:: " + item.PhysicalPath);
                        using (JsonTextReader reader = new JsonTextReader(file))
                        {
                            // 循环解析文件json数据
                            JObject jsonObject = (JObject)JToken.ReadFrom(reader);
                            JArray  jsonValues = (JArray)jsonObject["RECORDS"];
                            if (jsonValues.Count > 0)
                            {
                                var optionsBuilder = new DbContextOptionsBuilder <db_MicroStationContext>();
                                optionsBuilder.UseMySql(common.coon);
                                using (var context = new db_MicroStationContext(optionsBuilder.Options))
                                {
                                    foreach (var value in jsonValues)
                                    {
                                        string srcOid = (string)value["id"];
                                        Console.WriteLine("srcOid:: " + srcOid);

                                        string taskType = (string)value["taskType"];
                                        string subtype  = (string)value["subtype"];
                                        if (!(taskType == "2"))
                                        {
                                            continue;
                                        }

                                        if ((string)value["taskObjective"] == null)
                                        {
                                            continue;
                                        }
                                        var taskObj = (JObject)JToken.Parse((string)value["taskObjective"]);

                                        if (taskObj["entMessageList"] == null)
                                        {
                                            continue;
                                        }
                                        var listTrac = (JArray)taskObj["entMessageList"];
                                        if (listTrac.Count < 1)
                                        {
                                            continue;
                                        }

                                        var query = context.TaskOrder.AsQueryable().Where("Taskid = @0", srcOid);
                                        if (query.Count() > 0)
                                        {
                                            continue;
                                        }
                                        try
                                        {
                                            // 循环企业清单列表
                                            foreach (var trace in listTrac)
                                            {
                                                TaskOrder obj = new TaskOrder
                                                {
                                                    TaskOrderOid   = Guid.NewGuid().ToString("D"),
                                                    Taskid         = (string)value["id"],
                                                    TaskTypeSrc    = taskType,
                                                    TaskTypesubSrc = subtype,
                                                    Tasktitle      = (string)value["brief"],
                                                    Tasktype       = (string)value["targetType"],
                                                    Taskstatus     = (string)value["status"] == "ASSIGNING" ? "待查收" : (string)value["status"],
                                                    Taskobjectname = (string)value["targetName"],
                                                    TaskTownStreet = (string)taskObj["townName"],
                                                    TaskCommunity  = ((string)taskObj["warningTargetName"]).Split("-")[0],

                                                    AlarmStationnumber = (int)taskObj["warningTargetId"],
                                                    AlarmStationname   = (string)taskObj["warningTargetName"],
                                                    Alarmcontent       = (string)taskObj["warningContent"],
                                                    Alarmtime          = (DateTime)taskObj["dataTime"],
                                                    Alarmfactor        = (string)taskObj["warningFactory"],

                                                    Tasksubobjectname       = (string)trace["targetName"],
                                                    TasksubobjectOrgcode    = (string)trace["orgCode"],
                                                    TasksubTownStreet       = (string)trace["townName"],
                                                    TasksubCommunity        = (string)trace["streetName"],
                                                    Tasksubobjectaddress    = (string)trace["addr"],
                                                    Contributionrateranking = (int)trace["rank"],
                                                    Contributionrate        = (float)trace["rate"],

                                                    //Contributionrate= (float)value["warningIndicator"],
                                                    //Contributionrateranking = (int)value["warningIndicator"],

                                                    Collectorid       = (string)taskObj["agentId"],
                                                    Collector         = (string)taskObj["agentName"],
                                                    Collectorphone    = (string)taskObj["agentContact"],
                                                    CollectorunitId   = (string)taskObj["agentOrgId"],
                                                    CollectorunitName = (string)taskObj["agentOrgName"],

                                                    Taskcontent        = (string)value["detail"],
                                                    Tasknotes          = (string)value["remark"],
                                                    Taskstarttime      = (DateTime)value["implStartTime"],
                                                    Taskdeadline       = (DateTime)value["implEndTime"],
                                                    Taskreceivingtime  = DateTime.Now,
                                                    Taskfallback       = (ulong?)(((string)value["backReason"]) + "" == "" ? 0 : 1),
                                                    Taskfallbackreason = (string)value["backReason"],

                                                    //Checktime = null,
                                                    //Taskfeedbacktimes = 0,
                                                    //Taskfeedbacktime = null,
                                                    //Taskcompletetime = null,
                                                    Taskstatusupdatetime = DateTime.Now
                                                };
                                                if (!string.IsNullOrEmpty((string)value["Taskfallbacktime"]))
                                                {
                                                    obj.Taskfallbacktime = (DateTime)value["Taskfallbacktime"];
                                                }
                                                context.Add(obj);

                                                //TaskOrder objSub = obj.
                                                //Taskobjectaddress = (string)value["targetAddress"],
                                                //TaskTraceability objTrac = new TaskTraceability
                                                //{
                                                //    TaskTraceabilityOid = Guid.NewGuid().ToString("D"),
                                                //    Taskordeid = obj.TaskOrderOid,
                                                //    Taskid = obj.Taskid,
                                                //    Sitecode = (int)trace["stationCode"],
                                                //    TargetName = (string)trace["targetName"],
                                                //    TownStreet = (string)trace["townName"],
                                                //    OrgCode = (string)trace["orgCode"],
                                                //    TargetAddr = (string)trace["addr"],
                                                //    PollutionRank = (int)trace["rank"],
                                                //    PollutionRate = (float)trace["rate"]
                                                //};
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            Console.WriteLine("err srcID::" + srcOid);
                                            errs.Add((string)value["id"]);
                                            throw;
                                        }
                                    }
                                    result = context.SaveChanges();
                                    Console.WriteLine("res count::" + result.ToString());

                                    // 记录操作
                                    TaskDocking docking = new TaskDocking
                                    {
                                        TaskDockingOid = Guid.NewGuid().ToString("D"),
                                        Filename       = item.Name,
                                        Filepath       = item.PhysicalPath,
                                        Dockingtype    = "站点任务",
                                        AssociationId  = "",
                                        Dockingmode    = "download",
                                        Dockingtime    = DateTime.Now,
                                        Dockingresults = errs.Count > 0 ? "失败" : "完成",
                                        Dockingtimes   = 1,
                                        Dockmark       = string.Join(",", errs),
                                        Createtime     = DateTime.Now
                                    };
                                    context.Add(docking);
                                    int result2 = context.SaveChanges();
                                }
                            }
                            Task.Run(() =>
                            {
                            });
                        }
                    }

                    // 转移文件
                    if (result > errs.Count || errs.Count == 0)
                    {
                        File.Copy(item.PhysicalPath, Directory.GetCurrentDirectory() + @"/ftpData/task_old/" + item.Name);
                        Thread.Sleep(1000);
                        File.Delete(item.PhysicalPath);
                    }
                }
            }
        }
예제 #8
0
        public void DoUpdata_Task_back()
        {
            // 任务回退信息
            DateTime dtStart = getDock_time(true, "站点任务-反馈");
            DateTime dtEnd   = DateTime.Now;

            string sql   = "Taskfeedbacktime > @0 And Taskfeedbacktime <= @1";
            var    query = _context.TaskFeedback
                           .AsQueryable()
                           .Where(sql, dtStart, dtEnd)
                           .OrderBy(e => e.Taskfeedbacktime);

            if (query.Count() == 0)
            {
                return;
            }

            int    size = 100, page = 1;
            var    queryFen = query.Skip(size * (page - 1)).Take(size);
            int    ind      = 1;
            JArray datas    = new JArray();

            foreach (var item in query)
            {
                JObject data = new JObject();
                data["taskType"]        = item.TaskTypeSrc;
                data["subType"]         = item.TaskTypesubSrc;
                data["excelTemplate"]   = null;
                data["id"]              = item.Taskfeedbacktimes;
                data["completeRate"]    = item.Taskstatus == "已完成" ? 100 : 0;
                data["feedbackTime"]    = ((DateTime)item.Taskfeedbacktime).ToString("yyyy-MM-dd hh:mm:ss");
                data["feedbackType"]    = item.Taskstatus == "已完成" ? 0 : item.Taskstatus == "开展中" ? 1 : 2;
                data["feedbackContent"] = item.Supervision;

                //APP反馈选择,当选择是 / 否时,提交到平台的内容改为对应的文字。
                //对应关系:
                //是否需要整改:是 - 需要整改;否 - 不需要整改;
                //是否需要执法:是 - 需要执法;否 - 不需要执法;
                //是否需要处罚:是 - 需要处罚;否 - 不需要处罚。
                data["isItnecessaryToRectify"]    = item.Isitnecessarytorectify == 1 ? "需要整改" : "不需要整改";
                data["isLawEnforcementNecessary"] = item.Islawenforcementnecessary == 1 ? "需要执法" : "不需要执法";
                data["isItnecessaryToPunish"]     = item.Isitnecessarytopunish == 1 ? "需要处罚" : "不需要处罚";
                if (item.Taskstatus != "开展中")
                {
                    data["isItnecessaryToRectify"]    = null;
                    data["isLawEnforcementNecessary"] = null;
                    data["isItnecessaryToPunish"]     = null;
                }
                data["taskId"]         = item.Taskid;
                data["taskStatus"]     = item.Taskstatus;
                data["tasktargetName"] = item.Taskobjectname;
                data["imgUrlList"]     = checkFileNames(item.Picturenames, dtEnd, ref ind);
                data["attach"]         = null;
                datas.Add(data);
            }

            // 保存文件
            var    result   = JsonConvert.SerializeObject(new { RECORDS = datas });
            string fileName = "fk_" + dtEnd.ToString("yyyyMMdd_hhmm") + ".json";
            string strPath  = Directory.GetCurrentDirectory() + @"/ftpData/taskfeed/" + dtEnd.ToString("yyyyMM") + "/" + dtEnd.ToString("yyyyMMdd") + "/" + fileName;

            this.checkFileFloder(strPath);
            FileStream fileStream = new FileStream(strPath, FileMode.CreateNew);

            using (StreamWriter writer = new StreamWriter(fileStream))
            {
                writer.Write(result);
            }

            // 记录对接信息
            TaskDocking docking = new TaskDocking
            {
                TaskDockingOid = Guid.NewGuid().ToString("D"),
                Filename       = fileName,
                Filepath       = strPath,
                Dockingtype    = "站点任务-反馈",
                AssociationId  = "",
                Dockingmode    = "upload",
                Dockingtime    = DateTime.Now,
                Dockingresults = (File.Exists(strPath)) ? "完成" : "失败",
                Dockingtimes   = 1,
                Dockmark       = "",
                Createtime     = DateTime.Now
            };

            _context.Add(docking);
            int result2 = _context.SaveChanges();
        }
예제 #9
0
        public ActionResult <string> add(dynamic param)
        {
            var    jsonParams = JsonConvert.DeserializeObject <dynamic>(param.ToString());
            string Filename   = Convert.ToString(jsonParams.Filename);

            // 按文件名识别文件格式信息
            DateTime dtNow          = DateTime.Now;
            DateTime Createtime     = DateTime.Now;
            var      Dockingtype    = "任务工单";
            var      AssociationId  = "";
            var      Dockingresults = "";
            int      Dockingtimes   = 1;

            // 查询是否已入库
            TaskDocking docking = null;
            var         query   = _context.TaskDocking.Where(s => s.Filename == Filename).OrderByDescending(b => b.Createtime);

            if (query.Count() >= 1)
            {
                docking      = query.Take(1).Single();
                Dockingtimes = (int)(docking.Dockingtimes + 1);
                Createtime   = (DateTime)docking.Createtime;
            }
            // 按类型操作
            dynamic res = false;

            switch (Dockingtype)
            {
            case "任务工单":
                res = addTask(param);
                break;

            case "告警":
                res = addTask(param);
                break;

            default:
                break;
            }
            Dockingresults = res.result ? "完成" : "失败";

            // 创建或更新对象
            if (docking == null)
            {
                docking = new TaskDocking
                {
                    TaskDockingOid = Guid.NewGuid().ToString("D"),
                    Filename       = jsonParams.Filename,
                    Filepath       = jsonParams.Filepath,
                    Dockingtype    = Dockingtype,
                    AssociationId  = AssociationId,
                    Dockingmode    = jsonParams.Dockingmode,    //download/upload
                    Dockingresults = Dockingresults,
                    Dockingtimes   = Dockingtimes,
                    Dockingtime    = dtNow,
                    Createtime     = dtNow
                };
                _context.Add(docking);
            }
            else
            {
                docking.Dockingresults = Dockingresults;
                docking.Dockingtimes  += 1;
                docking.Dockingtime    = dtNow;
            }
            int result = _context.SaveChanges();
            var data   = new { TaskOrderOid = docking.TaskDockingOid, result = res.result };

            return(common.transResult(data));
        }