public static void Run(IMappingService mappingService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user)
        {
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_سینک_مپینگ);

            //The order of the execution on the commands is important
            //First-remove
            //Second-addOrUpdate

            try
            {
                SyncRemoveAllMappings(mappingService);
                SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.حذف_مپینگ_ها);
            }
            catch (Exception e)
            {
                SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.مشکل_در_حذف_مپینگ_ها);
            }

            // SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_اضافه_و_آپدیت_نمودن_مپینگ);

            SyncAddOrUpdateMappings(mappingService, logService, logTypeService, userService, user);

            //  SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.پایان_اضافه_و_آپدیت_نمودن_مپینگ);



            //var resualt = new ReturnValue
            //{
            //    Remove = remove,
            //    AddOrUpdate = addOrUpdate
            //};
            //return resualt;
        }
        //ترم-Add Or Update
        public static void SyncAddOrUpdateTerms(ITermService termService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user)
        {
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_سینک_ترم);

            var terms = new List <Term>();

            try
            {
                terms = ClientHelper.GetValue <Term>(StaticValue.TermRelativeAddress);
                SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دریافت_ترم_از_سرویس);
            }
            catch (Exception e)
            {
                SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عدم_دریافت_ترم_از_سرویس);
            }


            var resualt = new Dictionary <string, int>();
            var counter = 1;

            //SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_اضافه_و_آپدیت_نمودن_ترم);

            terms.ForEach(x =>
            {
                if (x != null)
                {
                    if (string.IsNullOrEmpty(x.TermCode))
                    {
                        resualt.Add($"{x.Name}-{counter}", 3);
                    }
                    else
                    {
                        var r = termService.AddOrUpdate(x);

                        // resualt.Add($"{x.Name}-{counter}", r.GetAddOrUpdateResualt());
                        resualt.Add($"{x.Name}-{counter}", r);
                    }
                }
                ++counter;
            });
            var added          = resualt.Count(x => x.Value == 1);
            var updatetd       = resualt.Count(x => x.Value == 2);
            var warrning       = resualt.Count(x => x.Value == 3);
            var stringWarrning = string.Empty;

            foreach (var s in resualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringWarrning += $"تعداد {warrning}" + " || " + s + " | ";
            }
            stringWarrning = !string.IsNullOrEmpty(stringWarrning.Trim()) ? stringWarrning : "بدون مشکل";
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.ترم_اضافه_شد, $"تعداد {added}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.ترم_آپدیت_شد, $"تعداد {updatetd}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.مشکل_در_اضافه_و_آپدیت_کردن_ترم, stringWarrning);


            //SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.پایان_اضافه_و_آپدیت_نمودن_ترم);

            // return resualt;
        }
        //مپینگ-AddOrUpdate
        public static void SyncAddOrUpdateMappings(IMappingService mappingService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user)
        {
            var mappings = ClientHelper.GetValue <MappingSyncModel>(StaticValue.MappingRelativeAddress);

            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دریافت_مپینگ_از_سرویس);

            var resualt = new Dictionary <string, int>();

            var counter = 1;


            mappings.ForEach(x =>
            {
                if (x != null)
                {
                    if (x.TypeId == 0 || x.MappingTypeId == 0 || string.IsNullOrEmpty(x.TypeName))
                    {
                        resualt.Add($"{counter}- کد نوع نگاشت:{x.MappingTypeId}-{x.TypeId}-{x.TypeName}", 4);
                    }
                    else
                    {
                        var r = mappingService.AddOrUpdate(x);
                        resualt.Add($"{counter}- کد نوع نگاشت:{x.MappingTypeId}-{x.TypeId}-{x.TypeName}", r);
                    }
                }
                ++counter;
            });



            var added            = resualt.Count(x => x.Value == 1);
            var updatetd         = resualt.Count(x => x.Value == 2);
            var warrning         = resualt.Count(x => x.Value == 3);
            var notFounded       = resualt.Count(x => x.Value == 4);
            var stringWarrning   = string.Empty;
            var stringNotFounded = string.Empty;

            foreach (var s in resualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringWarrning += $"تعداد {warrning}" + " || " + s + " | ";
            }
            foreach (var s in resualt.Where(x => x.Value == 4).Select(x => x.Key))
            {
                stringNotFounded += $"تعداد {notFounded}" + " || " + s + " | ";
            }

            stringWarrning   = !string.IsNullOrEmpty(stringWarrning.Trim()) ? stringWarrning : "بدون مشکل";
            stringNotFounded = !string.IsNullOrEmpty(stringNotFounded.Trim()) ? stringNotFounded : "بدون مشکل";

            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.مپینگ_اضافه_گردید, $"تعداد {added}");
            //SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.مپینگ_آپدیت_گردید, $"تعداد {updatetd}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.مشکل_در_اضافه_و_آپدیت_کردن_مپینگ, stringWarrning);
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.یکی_از_مقادیر_نگاشت_موجود_نمی, stringNotFounded);



            // return result;
        }
        //دانشجو-کلاس-Add Or Update
        public static void SyncAddOrUpdateStudentEducationalClass(
            IStudentEducationalClassService studentEducationalClassService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user, string termCode)
        {
            var studentEducationalClasses =
                ClientHelper.GetValue <StudentEducationalClassSyncModel>(StaticValue.StudentEducationalClass + $"/{termCode}");

            //log get From service
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دریافت_دانشجو_کلاس_از_سرویس);


            var addOrUpdateResualt = new Dictionary <string, int>();
            var counter            = 1;

            studentEducationalClasses.ForEach(x =>
            {
                if (x != null)
                {
                    if (HasNullValue(x))
                    {
                        addOrUpdateResualt.Add($"{x.EducationalClassId}-{x.StudentId}-{counter}", 4);
                    }
                    else
                    {
                        var r = studentEducationalClassService.AddOrUpdate(x);
                        addOrUpdateResualt.Add($"{x.EducationalClassId}-{x.StudentId}-{counter}", r);
                    }
                }
                ++counter;
            });

            var added            = addOrUpdateResualt.Count(x => x.Value == 1);
            var updatetd         = addOrUpdateResualt.Count(x => x.Value == 2);
            var warrning         = addOrUpdateResualt.Count(x => x.Value == 3);
            var notFounded       = addOrUpdateResualt.Count(x => x.Value == 4);
            var stringWarrning   = string.Empty;
            var stringNotFounded = string.Empty;

            foreach (var s in addOrUpdateResualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringWarrning = $"تعداد {warrning}" + " || " + s + " | ";
            }
            foreach (var s in addOrUpdateResualt.Where(x => x.Value == 4).Select(x => x.Key))
            {
                stringNotFounded = $"تعداد {notFounded}" + " || " + s + " | ";
            }

            stringWarrning   = !string.IsNullOrEmpty(stringWarrning.Trim()) ? stringWarrning : "بدون مشکل";
            stringNotFounded = !string.IsNullOrEmpty(stringNotFounded.Trim()) ? stringNotFounded : "بدون مشکل";

            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دانشجو_کلاس_اضافه_گردید, $"تعداد {added}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دانشجو_کلاس_آپدیت_گردید, $"تعداد {updatetd}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_در_بروزرسانی_دانشجو_کلاس, stringWarrning);
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_به_دلیل_عدم_وجود_حداقل_یک_مقدار_از_دانشجو_کلاس, stringNotFounded);


            // return addOrUpdateResualt;
        }
        //دانشکده-Add Or Update
        public static void SyncAddOrUpdateColleges(ICollegeService collegeService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user)
        {
            var colleges = ClientHelper.GetValue <College>(StaticValue.CollegeRelativeAddress);

            //2.log
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دریافت_دانشکده_از_سرویس);


            var resualt = new Dictionary <string, int>();
            var counter = 1;

            colleges.ForEach(x =>
            {
                if (x != null)
                {
                    if (x.CollegeCode == null || x.CollegeCode == 0 || string.IsNullOrEmpty(x.Name))
                    {
                        resualt.Add($"{x.Name}-{x.CollegeCode}-{counter}", 4);
                    }
                    var r = collegeService.AddOrUpdate(x);
                    resualt.Add($"{x.Name}-{x.CollegeCode}-{counter}", r);
                }
                ++counter;
            });


            var added            = resualt.Count(x => x.Value == 1);
            var updatetd         = resualt.Count(x => x.Value == 2);
            var warrning         = resualt.Count(x => x.Value == 3);
            var notFounded       = resualt.Count(x => x.Value == 4);
            var stringWarrning   = string.Empty;
            var stringNotFounded = string.Empty;

            foreach (var s in resualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringWarrning += $"تعداد {warrning}" + " || " + s + " | ";
            }
            foreach (var s in resualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringNotFounded += $"تعداد {notFounded}" + " || " + s + " | ";
            }

            stringWarrning   = !string.IsNullOrEmpty(stringWarrning.Trim()) ? stringWarrning : "بدون مشکل";
            stringNotFounded = !string.IsNullOrEmpty(stringNotFounded.Trim()) ? stringNotFounded : "بدون مشکل";

            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دانشکده_اضافه_گردید, $"تعداد {added}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دانشکده_آپدیت_گردید, $"تعداد {updatetd}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_در_بروزرسانی_دانشکده, stringWarrning);
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_به_دلیل_عدم_وجود_حداقل_یک_مقدار_از_دانشکده, stringNotFounded);


            //return resualt;
        }
        public static void Run(ICollegeService collegeService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user)
        {
            //The order of the execution on the commands is important
            //First-remove
            //Second-addOrUpdate

            //1.log
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_سینک_دانشکده);


            //var remove = SyncRemoveColleges(collegeService);
            SyncAddOrUpdateColleges(collegeService, logService, logTypeService, userService, user);

            //var resualt = new ReturnValue
            //{
            //    //Remove = remove,
            //    AddOrUpdate = addOrUpdate
            //};
            //return resualt;
        }
Exemple #7
0
        public static void Run(IEducationalClassService educationalClassService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user, string termCode)
        {
            //The order of the execution on the commands is important
            //First-remove
            //Second-addOrUpdate

            //log start
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.شروع_سینک_کلاس);


            // var remove = SyncRemoveEducationalClass(educationalClassService);
            SyncAddOrUpdateEducationalClass(educationalClassService, logService, logTypeService, userService, user, termCode);

            //var resualt = new ReturnValue
            //{
            //    //Remove = remove,
            //    AddOrUpdate = addOrUpdate
            //};
            //return resualt;
        }
Exemple #8
0
        //کلاس-Add Or Update
        public static void SyncAddOrUpdateEducationalClass(IEducationalClassService educationalClassService, ILogService logService, ILogTypeService logTypeService, IUserService userService, User user, string termCode)
        {
            var educationalClasses = ClientHelper.GetValue <EducationalClassSyncModel>(StaticValue.EducationalClassRelativeAddress + $"/{termCode}");

            //log get From service
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.دریافت_کلاس_از_سرویس);

            var addOrUpdateResualt   = new Dictionary <string, int>();
            var counter              = 1;
            var preventedContentType = new List <int?> {
                10, 11, 24, 7, 6, 49, 50, 38
            };
            var preventedHoldingType = new List <decimal?> {
                5, 7
            };

            if (educationalClasses != null)
            {
                var exceptions = educationalClasses.Where(w => preventedContentType.Contains(w.ContentType) ||
                                                          preventedHoldingType.Contains(w.HoldingType) || w.HoldingExamDate == null);
                educationalClasses.Except(exceptions).ToList().ForEach(x =>
                {
                    if (x.ContentType != null && !preventedContentType.Contains(x.ContentType) &&
                        x.HoldingExamDate != null &&
                        x.HoldingType != null && !preventedHoldingType.Contains(x.HoldingType))
                    {
                        if (x != null)
                        {
                            if (HasNullProperty(x))
                            {
                                addOrUpdateResualt.Add($"{x.GroupId}-{x.CodeClass}-{x.Name}-{counter}", 4);
                            }
                            else
                            {
                                var r = educationalClassService.AddOrUpdate(x);
                                addOrUpdateResualt.Add($"{x.GroupId}-{x.CodeClass}-{x.Name}-{counter}", r);
                            }
                        }
                        ++counter;
                    }
                });
            }
            var added            = addOrUpdateResualt.Count(x => x.Value == 1);
            var updatetd         = addOrUpdateResualt.Count(x => x.Value == 2);
            var warrning         = addOrUpdateResualt.Count(x => x.Value == 3);
            var notFounded       = addOrUpdateResualt.Count(x => x.Value == 4);
            var stringWarrning   = string.Empty;
            var stringNotFounded = string.Empty;

            foreach (var s in addOrUpdateResualt.Where(x => x.Value == 3).Select(x => x.Key))
            {
                stringWarrning = $"تعداد {warrning}" + " || " + s + " | ";
            }
            foreach (var s in addOrUpdateResualt.Where(x => x.Value == 4).Select(x => x.Key))
            {
                stringNotFounded = $"تعداد {notFounded}" + " || " + s + " | ";
            }

            stringWarrning   = !string.IsNullOrEmpty(stringWarrning.Trim()) ? stringWarrning : "بدون مشکل";
            stringNotFounded = !string.IsNullOrEmpty(stringNotFounded.Trim()) ? stringNotFounded : "بدون مشکل";

            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.کلاس_اضافه_گردید, $"تعداد {added}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.کلاس_آپدیت_گردید, $"تعداد {updatetd}");
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_در_بروزرسانی_کلاس, stringWarrning);
            SyncService.LogSync(logService, logTypeService, userService, user, (int)LogTypeValue.عملیات_ناموفق_به_دلیل_عدم_وجود_حداقل_یک_مقدار_از_کلاس, stringNotFounded);

            //return result;
        }