コード例 #1
0
        public void GetMachineConnectData(DateTime date)
        {
            appData appdata = new appData();

            appdata = DatabaseAccess.GetMachineConnectData(date);
            try
            {
                if (appdata.PlantMachine.Count > 0)
                {
                    string json = JsonConvert.SerializeObject(appdata,
                                                              new JsonSerializerSettings
                    {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    });
                    var dtname = date.ToString("yyyy-MM-dd");


                    if (!string.IsNullOrEmpty(IISDataFolderPath))
                    {
                        if (!Directory.Exists(IISDataFolderPath))
                        {
                            try
                            {
                                Directory.CreateDirectory(IISDataFolderPath);
                            }
                            catch (Exception exx)
                            {
                                Logger.WriteErrorLog(exx.ToString());
                            }
                        }
                        if (Directory.Exists(IISDataFolderPath))
                        {
                            File.WriteAllText(Path.Combine(IISDataFolderPath, dtname + ".json"), json);
                        }
                    }
                    if (!string.IsNullOrEmpty(CloudWebAPIURLToUploadFile))
                    {
                        if (!Directory.Exists(Path.Combine(appPath, "Data")))
                        {
                            Directory.CreateDirectory(Path.Combine(appPath, "Data"));
                        }
                        var filePath = Path.Combine(appPath, "data", dtname + ".json");

                        File.WriteAllText(filePath, json);
                        Upload(Path.Combine(filePath));
                    }

                    //////////////////
                    //if (!Directory.Exists(IISDataFolderPath))
                    //{
                    //    Directory.CreateDirectory(IISDataFolderPath);
                    //}
                    //File.WriteAllText(Path.Combine(IISDataFolderPath, dtname + ".json"), json);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }
        }
コード例 #2
0
ファイル: appData.Designer.cs プロジェクト: NixesEA/fin
        public override global::System.Data.DataSet Clone()
        {
            appData cln = ((appData)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
コード例 #3
0
ファイル: db.cs プロジェクト: amhrezazade/Yara
 public static async Task Save(appData data)
 {
     try
     {
         string txt = JsonConvert.SerializeObject(data);
         await File.WriteAllTextAsync(localFileName, txt);
     }
     catch //(Exception ex)
     {
         return;
     }
 }
コード例 #4
0
ファイル: appData.Designer.cs プロジェクト: NixesEA/fin
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            appData ds = new appData();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
コード例 #5
0
 public MainActivityService()
 {
     _data = db.Load();
 }
        internal static appData GetMachineConnectData(DateTime dateVal)
        {
            SqlConnection conn             = ConnectionManager.GetConnection();
            DataTable     dt               = new DataTable();
            DataTable     dtMachine        = new DataTable();
            DataTable     dtDashboard      = new DataTable();
            DataTable     dtPartCount      = new DataTable();
            DataTable     dtTimes          = new DataTable();
            DataTable     dtStoppages      = new DataTable();
            DataTable     dtAlarmsDatails  = new DataTable();
            DataTable     dtAlarmsSummary  = new DataTable();
            DataTable     dtAlarmsSolution = new DataTable();

            appData appData = new appData();

            appData.Shifts         = new List <Shift>();
            appData.PlantMachine   = new List <PlantMachines>();
            appData.AlarmsSolution = new List <AlarmSolution>();
            var ss = dateVal.ToString("yyyy-MM-dd");

            try
            {
                var cmd = new SqlCommand("[dbo].[FocasWeb_ViewShift&HourwiseSummary]", conn);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 120;
                cmd.Parameters.AddWithValue("@Date", dateVal.ToString("yyyy-MM-dd"));//dateVal);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        int   shiftId = 0;
                        Shift shift   = new Shift();
                        if (int.TryParse(rdr["ShiftID"].ToString(), out shiftId))
                        {
                            shift.ShiftId = shiftId;
                        }
                        shift.ShiftName = rdr["ShiftName"].ToString();
                        appData.Shifts.Add(shift);
                    }
                    rdr.NextResult();
                    while (rdr.Read())
                    {
                        int           plantId       = 0;
                        PlantMachines plantMachines = new PlantMachines();
                        if (int.TryParse(rdr["PlantCode"].ToString(), out plantId))
                        {
                            plantMachines.PlantID = plantId;
                        }
                        plantMachines.PlantName = rdr["Plantid"].ToString();
                        appData.PlantMachine.Add(plantMachines);
                    }
                    rdr.NextResult();

                    //--MachineInformation---
                    dtMachine.Load(rdr);
                    //---Dashboard Information-----
                    dtDashboard.Load(rdr);
                    //-----PartCount Information---
                    dtPartCount.Load(rdr);

                    dtTimes.Load(rdr);

                    dtStoppages.Load(rdr);

                    dtAlarmsDatails.Load(rdr);

                    dtAlarmsSummary.Load(rdr);

                    //dtAlarmsSolution.Load(rdr);

                    if (dtMachine.Rows.Count > 0)
                    {
                        for (int i = 0; i < appData.PlantMachine.Count; i++)
                        {
                            appData.PlantMachine[i].Machines = new List <Machine>();
                            foreach (DataRow item in dtMachine.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "'"))
                            {
                                int     machineId = 0;
                                Machine machine   = new Machine();
                                if (int.TryParse(item["MCInterface"].ToString(), out machineId))
                                {
                                    machine.MachineID = machineId;//Convert.ToInt32(item["MCInterface"].ToString());
                                }
                                machine.MachineName = item["MachineId"].ToString();
                                machine.LastProgram = item["RunningPart"].ToString();
                                machine.Downtime    = item["Stoppages"].ToString();
                                machine.Status      = item["McStatus"].ToString();
                                machine.Color       = item["color"].ToString();
                                if (int.TryParse(item["PartsCount"].ToString(), out machineId))
                                {
                                    machine.PartsCount = machineId;// int.Parse(item["PartsCount"].ToString());
                                }
                                machine.MachineMTB = item["MachineMTB"].ToString().ToUpper();

                                appData.PlantMachine[i].Machines.Add(machine);
                            }
                        }

                        appData.appDataList = new List <AppDataList>();
                        AppDataList appdataDay = new AppDataList();
                        appdataDay.Key     = dateVal.ToString("yyyy-MM-dd");
                        appdataDay.DayData = new List <DayData>();

                        for (int i = 0; i < appData.PlantMachine.Count; i++)
                        {
                            foreach (Machine item in appData.PlantMachine[i].Machines)
                            {
                                DayData dayData1 = new DayData();
                                dayData1.DataDate    = DateTime.Now.Date;
                                dayData1.MachineID   = item.MachineID;
                                dayData1.MachineName = item.MachineName;
                                dayData1.PlantID     = appData.PlantMachine[i].PlantID;
                                dayData1.PlantName   = appData.PlantMachine[i].PlantName;

                                dayData1.PartsCountData     = new List <PartsCountData>();
                                dayData1.PartCountChartData = new List <PartCountChartData>();

                                dayData1.TimesData      = new List <TimesData>();
                                dayData1.TimesChartData = new List <TimesChartData>();

                                dayData1.StoppagesData = new List <StoppagesData>();
                                dayData1.AlarmsDetails = new List <AlarmData>();
                                dayData1.AlarmsSummary = new List <AlarmData>();

                                dayData1.DashboardData = new DashboardData();
                                dayData1.DashboardData.DashboardDetails = new List <DashboardDetails>();
                                foreach (DataRow item1 in dtDashboard.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "'"))
                                {
                                    DashboardDetails dashboardDetails = new DashboardDetails();
                                    dashboardDetails.NavId         = item1["NavID"].ToString();
                                    dashboardDetails.ColHeaderText = item1["DisplayName"].ToString();

                                    dashboardDetails.ShiftData = new List <string>();
                                    foreach (var shifts in appData.Shifts)
                                    {
                                        dashboardDetails.ShiftData.Add(item1[shifts.ShiftName].ToString());
                                    }

                                    //dashboardDetails.ShiftData.Add(item1["A"].ToString());
                                    //dashboardDetails.ShiftData.Add(item1["B"].ToString());
                                    //dashboardDetails.ShiftData.Add(item1["C"].ToString());


                                    if (item1["NavID"].ToString().Equals("menu.partsCount", StringComparison.OrdinalIgnoreCase))
                                    {
                                        dayData1.DashboardData.PartCount = item1["DayValue"].ToString();
                                    }
                                    else if (item1["NavID"].ToString().Equals("menu.downtime", StringComparison.OrdinalIgnoreCase))
                                    {
                                        dayData1.DashboardData.DownTime = item1["DayValue"].ToString();
                                    }
                                    dayData1.DashboardData.DashboardDetails.Add(dashboardDetails);
                                }

                                dayData1.PartsCountData = new List <PartsCountData>();

                                //for each shift and machine fill the part count data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    PartsCountData     partCountData      = new PartsCountData();
                                    PartCountChartData partCountChartData = new PartCountChartData();
                                    partCountData.ShiftId   = partCountChartData.ShiftId = shift.ShiftId;
                                    partCountData.ShiftName = partCountChartData.ShiftName = shift.ShiftName;

                                    partCountData.details        = new List <PartsCountDetails>();
                                    partCountChartData.ChartData = new Chart <PartsCountSeries>();

                                    partCountChartData.ChartData.categories = new List <string>();
                                    partCountChartData.ChartData.series     = new List <PartsCountSeries>();

                                    var datarow = dtPartCount.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId);

                                    //----for part count chart----START--
                                    List <string> programs = datarow.Select(r => r["ProgramID"].ToString()).Distinct().ToList();
                                    programs.Remove("");
                                    List <int> id = datarow.Select(rr => Convert.ToInt32(rr["HourID"].ToString())).Distinct().ToList();
                                    foreach (string prog in programs)
                                    {
                                        List <int> dataSeries = new List <int>();
                                        id.ForEach(o => dataSeries.Add(0));//dataSeries.Add(int.MinValue));

                                        PartsCountSeries prog1 = new PartsCountSeries()
                                        {
                                            name = prog, data = dataSeries
                                        };
                                        partCountChartData.ChartData.series.Add(prog1);
                                        foreach (DataRow row in datarow.Where(r => r["ProgramID"].ToString() == prog))
                                        {
                                            int hourId = Int32.Parse(row["HourID"].ToString()) - 1;
                                            dataSeries[hourId] = Int32.Parse(row["PartCount"].ToString());
                                        }
                                    }
                                    //----for part count chart----END--
                                    foreach (DataRow item1 in datarow)
                                    {
                                        PartsCountDetails partShift = new PartsCountDetails();
                                        partShift.HourText   = Convert.ToDateTime(item1["HourStart"].ToString()).ToString("htt").ToLower() + "-" + Convert.ToDateTime(item1["HourEnd"].ToString()).ToString("htt").ToLower();
                                        partShift.Program    = item1["ProgramID"].ToString();
                                        partShift.PartsCount = item1["PartCount"].ToString();
                                        partCountData.details.Add(partShift);

                                        //----for part count chart------
                                        if (partCountChartData.ChartData.categories.Contains(partShift.HourText) == false)
                                        {
                                            partCountChartData.ChartData.categories.Add(partShift.HourText);
                                        }
                                    }
                                    dayData1.PartsCountData.Add(partCountData);
                                    dayData1.PartCountChartData.Add(partCountChartData);
                                }

                                dayData1.TimesData = new List <TimesData>();
                                //for each shift and machine fill the times data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    TimesData      timeData  = new TimesData();
                                    TimesChartData timeChart = new TimesChartData();
                                    timeData.ShiftId   = timeChart.ShiftId = shift.ShiftId;
                                    timeData.ShiftName = timeChart.ShiftName = shift.ShiftName;

                                    timeData.details = new List <TimesDetails>();

                                    timeChart.ChartData = new Chart <TimeDataSeries>();
                                    TimeDataSeries power = new TimeDataSeries()
                                    {
                                        name = "Power On Time", data = new List <int>()
                                    };
                                    TimeDataSeries operating = new TimeDataSeries()
                                    {
                                        name = "Operating Time", data = new List <int>()
                                    };
                                    TimeDataSeries cutting = new TimeDataSeries()
                                    {
                                        name = "CuttingTime", data = new List <int>()
                                    };

                                    timeChart.ChartData.categories = new List <string>();
                                    timeChart.ChartData.series     = new List <TimeDataSeries>();
                                    timeChart.ChartData.series.Add(power);
                                    timeChart.ChartData.series.Add(operating);
                                    timeChart.ChartData.series.Add(cutting);



                                    foreach (DataRow item1 in dtTimes.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        TimesDetails timeShift = new TimesDetails();

                                        timeShift.HourText = Convert.ToDateTime(item1["HourStart"].ToString()).ToString("htt").ToLower() + "-" + Convert.ToDateTime(item1["HourEnd"].ToString()).ToString("htt").ToLower();

                                        timeShift.PowerNo   = item1["PowerOntime"].ToString();
                                        timeShift.Operating = item1["OperatingTime"].ToString();
                                        timeShift.Cutting   = item1["CuttingTime"].ToString();
                                        timeData.TotalPOT   = item1["TotalPOT"].ToString();
                                        timeData.TotalOT    = item1["TotalOT"].ToString();
                                        timeData.TotalCT    = item1["TotalCT"].ToString();
                                        timeData.details.Add(timeShift);

                                        //for chart
                                        timeChart.ChartData.categories.Add(timeShift.HourText);
                                        power.data.Add(int.Parse(item1["PowerOntimeInt"].ToString()));
                                        operating.data.Add(int.Parse(item1["OperatingTimeInt"].ToString()));
                                        cutting.data.Add(int.Parse(item1["CuttingTimeInt"].ToString()));
                                    }
                                    dayData1.TimesData.Add(timeData);
                                    dayData1.TimesChartData.Add(timeChart);
                                }

                                dayData1.StoppagesData = new List <StoppagesData>();
                                //for each shift and machine fill the stoppages data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    StoppagesData stoppageData = new StoppagesData();
                                    stoppageData.ShiftId   = shift.ShiftId;
                                    stoppageData.ShiftName = shift.ShiftName;
                                    stoppageData.details   = new List <StoppagesDetails>();
                                    foreach (DataRow item1 in dtStoppages.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        StoppagesDetails stoppageShift = new StoppagesDetails();
                                        if (string.IsNullOrEmpty(item1["BatchStart"].ToString()))
                                        {
                                            stoppageShift.Fromtime = null;// Convert.ToDateTime(item1["BatchStart"].ToString());
                                        }
                                        else
                                        {
                                            stoppageShift.Fromtime = Convert.ToDateTime(item1["BatchStart"].ToString());
                                        }
                                        if (string.IsNullOrEmpty(item1["BatchEnd"].ToString()))
                                        {
                                            stoppageShift.ToTime = null;// Convert.ToDateTime(item1["BatchEnd"].ToString());
                                        }
                                        else
                                        {
                                            stoppageShift.ToTime = Convert.ToDateTime(item1["BatchEnd"].ToString());
                                        }
                                        stoppageShift.Duration = item1["Stoppagetime"].ToString();
                                        stoppageData.details.Add(stoppageShift);
                                    }
                                    dayData1.StoppagesData.Add(stoppageData);
                                }

                                //-----for each Alarm Details--------------------
                                foreach (Shift shift in appData.Shifts)
                                {
                                    AlarmData alarmData = new AlarmData();
                                    alarmData.ShiftId   = shift.ShiftId;
                                    alarmData.ShiftName = shift.ShiftName;
                                    alarmData.details   = new List <AlarmDetails>();
                                    foreach (DataRow item1 in dtAlarmsDatails.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        int          alarm        = 0;
                                        AlarmDetails alarmDetails = new AlarmDetails();
                                        if (int.TryParse(item1["AlarmNo"].ToString(), out alarm))
                                        {
                                            alarmDetails.alarmNo = alarm;
                                        }
                                        if (string.IsNullOrEmpty(item1["Fromtime"].ToString()))
                                        {
                                            alarmDetails.StartTime = null;// Convert.ToDateTime(item1["Fromtime"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.StartTime = Convert.ToDateTime(item1["Fromtime"].ToString());
                                        }

                                        if (string.IsNullOrEmpty(item1["Totime"].ToString()))
                                        {
                                            alarmDetails.EndTime = null;// Convert.ToDateTime(item1["Totime"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.EndTime = Convert.ToDateTime(item1["Totime"].ToString());
                                        }
                                        alarmDetails.Duration = item1["Duration"].ToString();
                                        alarmDetails.Message  = item1["AlarmMSG"].ToString();
                                        if (int.TryParse(item1["Shiftcount"].ToString(), out alarm))
                                        {
                                            alarmData.shiftCount = alarm;
                                        }
                                        alarmData.TotalDuration = item1["Totalduration"].ToString();
                                        alarmData.details.Add(alarmDetails);
                                    }
                                    dayData1.AlarmsDetails.Add(alarmData);
                                }
                                //---for each Alarm Summary--------------
                                foreach (Shift shift in appData.Shifts)
                                {
                                    AlarmData alarmData = new AlarmData();
                                    alarmData.ShiftId   = shift.ShiftId;
                                    alarmData.ShiftName = shift.ShiftName;
                                    alarmData.details   = new List <AlarmDetails>();
                                    foreach (DataRow item1 in dtAlarmsSummary.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        int          alarm        = 0;
                                        AlarmDetails alarmDetails = new AlarmDetails();
                                        if (int.TryParse(item1["AlarmNo"].ToString(), out alarm))
                                        {
                                            alarmDetails.alarmNo = alarm;
                                        }
                                        if (string.IsNullOrEmpty(item1["Lastseen"].ToString()))
                                        {
                                            alarmDetails.LastSeen = null;// Convert.ToDateTime(item1["Lastseen"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.LastSeen = Convert.ToDateTime(item1["Lastseen"].ToString());
                                        }
                                        alarmDetails.Message = item1["AlarmMSG"].ToString();
                                        if (int.TryParse(item1["NoOfOccurences"].ToString(), out alarm))
                                        {
                                            alarmDetails.NoOfOcc = alarm;
                                        }
                                        alarmData.details.Add(alarmDetails);
                                    }
                                    dayData1.AlarmsSummary.Add(alarmData);
                                }
                                appdataDay.DayData.Add(dayData1);
                            }
                        }
                        appData.appDataList.Add(appdataDay);
                    }
                    //if (dtAlarmsSolution.Columns.Count > 0)
                    //{
                    //    foreach (DataRow item in dtAlarmsSolution.Rows)
                    //    {
                    //        int slNo = 0;
                    //        AlarmSolution alarmSolution = new AlarmSolution();
                    //        if (int.TryParse(item["Slno"].ToString(), out slNo))
                    //            alarmSolution.SlNo = slNo;
                    //        if (int.TryParse(item["AlarmNo"].ToString(), out slNo))
                    //            alarmSolution.AlarmNo = slNo;
                    //        alarmSolution.ImageName = item["FilePath"].ToString();
                    //        alarmSolution.Description = item["Description"].ToString();
                    //        alarmSolution.Cause = item["Cause"].ToString();
                    //        alarmSolution.Solution = item["Solution"].ToString();
                    //        alarmSolution.MTB = item["MTB"].ToString().ToUpper();
                    //        appData.AlarmsSolution.Add(alarmSolution);
                    //    }
                    //}
                }
                if (!rdr.IsClosed)
                {
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }

            finally
            {
                conn.Close();
            }
            return(appData);
        }
コード例 #7
0
        public static async Task <string> RefreshData()
        {
            var res = await Server.Test();

            switch (res)
            {
            case Server.TestApiResult.DataNull:
            case Server.TestApiResult.TokenError:
                return("Login");

            case Server.TestApiResult.NetworkError:
                return("خطای اتصال به شبکه");

            case Server.TestApiResult.OK:
                break;

            default:
                return("خطا");
            }

            var data = new appData();


            var studentResult = await Api.GetStudetData();

            var TermListRes = await Api.GetTermList();

            var ActiveTermRes = await Api.GetActiveTermId();

            var imagebytes = await Server.GetProfileImageBytes(studentResult.data.ImageFileName);

            if (imagebytes != null)
            {
                await db.SaveProfileImage(imagebytes);
            }

            data.Home.Name        = studentResult.data.FirstName + " " + studentResult.data.LastName;
            data.Home.StudentCode = studentResult.data.StudentCode;
            data.Home.StudentId   = studentResult.data.StudentID.ToString();
            int ActiveTerm = ActiveTermRes.data.ActiveTerm;

            data.Home.activeterm = ActiveTerm.ToString();
            Lesson[] Lessons = null;
            foreach (var term in TermListRes.data)
            {
                if (term.Term == ActiveTerm)
                {
                    Lessons = term.Lessons;
                    break;
                }
            }
            if (Lessons == null)
            {
                return("خطا");
            }

            int practiceCount  = 0;
            int announcesCount = 0;
            int ResourcesCount = 0;

            foreach (var l in Lessons)
            {
                var AnnouncesRes = await Api.GetAnnounces(l.GroupID);

                var PracticesRes = await Api.GetPractices(l.GroupID);

                var LessonInfoRes = await Api.GetLessonInfo(l.GroupID);

                var ResourcesRes = await Api.GetResources(l.GroupID);


                var titel = new NotificationItem(l.LessonTitle, LessonInfoRes.data.LecturerLastName);

                if (AnnouncesRes.data.Length > 0)
                {
                    data.Announces.Add(new ContentItem());
                    data.Announces.Add(new ContentItem(titel));
                    foreach (var a in AnnouncesRes.data)
                    {
                        data.Announces.Add(new ContentItem(a));
                        if (a.SeenInfo == null)
                        {
                            announcesCount++;
                        }
                    }
                }

                if (ResourcesRes.data.Length > 0)
                {
                    data.Resources.Add(new ContentItem());
                    data.Resources.Add(new ContentItem(titel));
                    foreach (var a in ResourcesRes.data)
                    {
                        data.Resources.Add(new ContentItem(a));
                        ResourcesCount++;
                    }
                }

                List <Practices> insope   = new List <Practices>();
                List <Practices> answered = new List <Practices>();
                List <Practices> lost     = new List <Practices>();
                foreach (var p in PracticesRes.data)
                {
                    if (p.RegedAnswer == null)
                    {
                        if (p.InRegAnswerScope)
                        {
                            insope.Add(p);
                            practiceCount++;
                        }
                        else
                        {
                            lost.Add(p);
                        }
                    }
                    else
                    {
                        answered.Add(p);
                    }
                }

                if (insope.Count > 0)
                {
                    data.practicesList.InScope.Add(new ContentItem());
                    data.practicesList.InScope.Add(new ContentItem(titel));
                    foreach (var i in insope)
                    {
                        data.practicesList.InScope.Add(new ContentItem(i));
                    }
                }

                if (answered.Count > 0)
                {
                    data.practicesList.Answered.Add(new ContentItem());
                    data.practicesList.Answered.Add(new ContentItem(titel));
                    foreach (var i in answered)
                    {
                        data.practicesList.Answered.Add(new ContentItem(i));
                    }
                }

                if (lost.Count > 0)
                {
                    data.practicesList.Lost.Add(new ContentItem());
                    data.practicesList.Lost.Add(new ContentItem(titel));
                    foreach (var i in lost)
                    {
                        data.practicesList.Lost.Add(new ContentItem(i));
                    }
                }
            }

            data.Home.practicesText = practiceCount.ToString() + " تمرین آماده پاسخ  ";
            data.Home.announcesText = announcesCount.ToString() + " اعلان جدید  ";
            data.Home.resourcesText = ResourcesCount.ToString() + " منبع ";

            await db.Save(data);

            return("OK");
        }