1 Star 1 Fork 0

yxyc-137/Team collaboration calendar

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Main.cpp 23.52 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<fstream>
#include<ctime>
#include<cctype>
#include<vector>
#include<filesystem>
#include<chrono>
#include"global.h"
#include"month.h"
#include"riqi.h"
#include"day.h"
#include"schedule.h"
#include"main_interface.h"
#include"year.h"
#include"user.h"
#include"dialogue.h"
using namespace std;
//函数
const std::vector<year> get_year_vec();
//void welcome_interface();
void print_daiban_schedule();
string user_func(user u);
void list_chengyuan(vector<user>& user_vec);
//string get_wps_path();
//变量
vector<riqi>riqi_vec;//personal
vector<riqi>shared_riqi_vec;//shared
std::vector<year> year_vec = get_year_vec();
vector<user>user_vec = {user("user_name","user_secret","群主")};
vector<dialogue>dialogue_vec;
unsigned int message_number;
bool wuxinxiaoxi = true;
int main()
{
std::filesystem::path new_folder_path = "G:/我的云端硬盘/Multi-function_calendar_data";
std::filesystem::create_directories(new_folder_path);
//ofstream ofile2("G:/我的云端硬盘/Multi-function_calendar_data/users");
//if(!ofile2.is_open())
//{
// std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
// return 1;
//}
//ifstream ifile2("G:/我的云端硬盘/Multi-function_calendar_data/users");
//if(!ifile2.is_open())
//{
// std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
// return 2;
//}
/*vector<string>user_name_vec;
auto iter=back_inserter<vector<string>>(user_name_vec);
for(unsigned int i = 1;i <= 64;++i)
{
iter = std::to_string(i);
}*/
ofstream o_users_file;
o_users_file.open("G:/我的云端硬盘/Multi-function_calendar_data/users", ofstream::app);
if (!o_users_file.is_open())
{
cout << "操作失败:无法打开文件!" << endl;
return 5;
}
o_users_file.close();
ofstream o_dialogue_file;
o_dialogue_file.open("G:/我的云端硬盘/Multi-function_calendar_data/dialogue", ofstream::app);
if(!o_dialogue_file.is_open())
{
cout << "操作失败:无法打开文件!" << endl;
return -12;
}
o_dialogue_file.close();
ifstream i_users_file("G:/我的云端硬盘/Multi-function_calendar_data/users");
if(!i_users_file.is_open())
{
cout << "操作失败:无法打开文件!" << endl;
return 11;
}
//局部变量
string user_name;
string user_secret;
string user_shenfen;
getline(i_users_file, user_name);
getline(i_users_file, user_secret);
getline(i_users_file, user_shenfen);//消耗首个用户
while (getline(i_users_file, user_name)&& getline(i_users_file, user_secret)&& getline(i_users_file, user_shenfen))
{
user_vec.emplace_back(user_name,user_secret,user_shenfen);
}
ifstream i_dialogue_file("G:/我的云端硬盘/Multi-function_calendar_data/dialogue");
if(!i_dialogue_file.is_open())
{
cout << "操作失败:无法打开文件!" << endl;
return -13;
}
string message;
while(getline(i_dialogue_file, user_name) &&getline(i_dialogue_file, message))
{
int64_t count;
i_dialogue_file >> count;
i_dialogue_file.ignore();
std::chrono::time_point<std::chrono::steady_clock> produce_time = int64_to_time_point(count);
dialogue_vec.emplace_back(user_name, message,produce_time);
}
cout << "欢迎来到团队协作日历!\nl:登录\nr:注册\nc:注销\nv:查看用户\ne:退出\n";
while (true)
{
cout << "~$ ";
while (std::cin.peek() == '\n')
{
cout << "~$ ";
std::cin.ignore();
}
string command = "";
cin >> command;
if (command == "l")//log in
{
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
cout << "(按q退出)用户名:";
while (std::cin.peek() == '\n')
{
cout << "(按q退出)用户名:";
std::cin.ignore();
}
cin >> user_name;
if(user_name == "q")
{
cin.ignore();
continue;
}
/*auto iter2 = find(user_name_vec.cbegin(),user_name_vec.cend(),user_name);*/
if (user_vec.end()==find_if(user_vec.begin(),user_vec.end(),[&user_name](const user&u)->bool{return (u.get_user_name()==user_name);}))
{
cin.ignore();
cout << f_red << "操作失败:该用户不存在!" << reset << endl;
continue;
}
else//用户名正确
{
cin.ignore();
auto iter = find_if(user_vec.begin(), user_vec.end(), [&user_name](const user& u)->bool{return u.get_user_name() == user_name; });
cout << "(按q退出)密码:";
while(std::cin.peek() == '\n')
{
cout << "(按q退出)密码:";
std::cin.ignore();
}
cin >> user_secret;
cin.ignore();
if(user_secret == "q")
{
continue;
}
else if(user_secret == iter->get_user_secret())//密码正确
{
string s = user_func(*iter);
if(s == "back"||s=="b")
{
cin.ignore();
system("cls");
cout << "欢迎来到团队协作日历!\nl:登录\nr:注册\nc:注销\nv:查看用户\ne:退出\n" << reset;
continue;
}
else if(s == "exit"||s=="e")
{
cout << f_green << "感谢使用!" << reset << endl;
break;
}
else
{
cout << f_red << "程序异常终止!" << reset << endl;
exit(6);
}
}
else
{
cout << f_red << "操作失败:密码错误!" << reset << endl;
continue;
}
}
}
else if (command == "r")//register
{
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
cout << "(按q退出)用户名:";
while (std::cin.peek() == '\n')
{
cout << "(按q退出)用户名:";
std::cin.ignore();
}
cin >> user_name;
if(user_name == "q")
{
cin.ignore();
continue;
}
if (!(user_vec.end() ==
find_if(user_vec.begin(), user_vec.end(), [&user_name](const user& u)->bool{return (user_name==u.get_user_name()); })))//已存在
{
cin.ignore();
cout << f_red << "操作失败:该用户已经存在!" << reset << endl;
continue;
}
else//用户名合法
{
cin.ignore();
cout << "(按q退出)密码:";
while(std::cin.peek() == '\n')
{
cout << "(按q退出)密码:";
std::cin.ignore();
}
cin >> user_secret;
cin.ignore();
if(user_secret == "q")
{
continue;
}
if(user_secret.size() <= 5)
{
cout << f_red << "操作失败:密码至少应有6位数!"<<reset << endl;
continue;
}
user_vec.emplace_back(user_name,user_secret,"群成员");
cout << f_green << "注册成功!" << reset<<endl;
continue;
}
}
else if (command == "c")
{
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
cout << "(按q退出)用户名:";
while (std::cin.peek() == '\n')
{
cout << "(按q退出)用户名:";
std::cin.ignore();
}
cin >> user_name;
if(user_name == "q")
{
cin.ignore();
continue;
}
else if(user_name == "lisen")
{
cout <<f_red<< "操作失败:不能注销群主!" << reset << endl;
cin.ignore();
continue;
}
cin.ignore();
bool b = false;
for (auto iter = user_vec.begin(); iter != user_vec.end(); ++iter)
{
if (iter->get_user_name() == user_name)
{
cout << "(按q退出)密码:";
while(std::cin.peek() == '\n')
{
cout << "(按q退出)密码:";
std::cin.ignore();
}
cin >> user_secret;
cin.ignore();
if(user_secret == "q")
{
b = true;
break;
}
else if(user_secret == iter->get_user_secret())
{
user_vec.erase(iter);
ofstream ofile4("G:/我的云端硬盘/Multi-function_calendar_data/" + user_name, ofstream::trunc);
if(!ofile4.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << std::endl;
exit(7);
}
ofile4.close();
cout << f_green << "注销成功!" << reset << endl;
b = true;
break;
}
else
{
cout << f_red << "操作失败:密码错误!" << reset << endl;
continue;
}
}
}
if (b)
{
continue;
}
else//没有该用户
{
cout << f_red << "操作失败:该用户不存在!" << reset << endl;
continue;
}
}
else if(command == "v")
{
cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
list_chengyuan(user_vec);
continue;
}
else if (command == "e")
{
cout <<f_green<< "感谢使用!"<<reset<<endl;
break;
}
else
{
cout <<f_red<< "操作失败:输入格式不正确!" <<reset<< endl;
cin.clear();
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
continue;
}
}
o_users_file.open("G:/我的云端硬盘/Multi-function_calendar_data/users");
for (auto& ele : user_vec)
{
o_users_file << ele.get_user_name() << endl;
o_users_file << ele.get_user_secret() << endl;
o_users_file << ele.get_user_shenfen() << endl;
}
o_users_file.close();
o_dialogue_file.open("G:/我的云端硬盘/Multi-function_calendar_data/dialogue");
for(auto& ele : dialogue_vec)
{
o_dialogue_file << ele.get_user_name() << endl;
o_dialogue_file << ele.get_dial() << endl;
o_dialogue_file << time_point_to_int64 (ele.get_produce_time())<< endl;
}
o_dialogue_file.close();
system("pause");
return 0;
}
void print_daiban_schedule()
{
if(wuxinxiaoxi)
{
cout << f_green << "无新消息" << reset << endl;
}
else
{
cout << f_red << "有新消息,按d查看" << reset << endl;
}
if (year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_schedule_number() == 0)
{
cout <<f_green<< "今天无日程" <<reset<< endl;
}
else if(year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_personal_schedule_number()!=0&& year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_team_schedule_number()==0)
{
cout <<f_red<< "今天日程" <<reset<< endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
/*cout << "无团队" << endl;*/
}
else if (year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_personal_schedule_number() == 0 && year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_team_schedule_number() != 0)
{
cout <<f_red<< "今天日程" <<reset<< endl;
/* cout << "无个人" << endl;*/
cout << "团队:" << endl;
int j = 1;
for (auto ele : year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
else
{
cout <<f_red<< "今天日程" <<reset<< endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
cout << "团队:" << endl;
j = 1;
for (auto ele : year_vec[now_year - 2023].get_month_arr()[now_month - 1].get_day_vec()[now_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
//std::cout << "***************" << endl;
auto n_year = nextDay(now_year,now_month,now_day)[0];
auto n_month = nextDay(now_year,now_month,now_day)[1];
auto n_day = nextDay(now_year,now_month,now_day)[2];
if (year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_schedule_number() == 0)
{
cout <<f_green<< "明天无日程" <<reset<< endl;
}
else if(year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_personal_schedule_number()!=0&& year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_team_schedule_number()==0)
{
cout <<f_red<< "明天日程" <<reset<< endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
/*cout << "无团队" << endl;*/
}
else if (year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_personal_schedule_number() == 0 && year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_team_schedule_number() != 0)
{
cout <<f_red<< "明天日程" <<reset<< endl;
/* cout << "无个人" << endl;*/
cout << "团队:" << endl;
int j = 1;
for (auto ele : year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
else
{
cout <<f_red<< "明天日程" <<reset<< endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
cout << "团队:" << endl;
j = 1;
for (auto ele : year_vec[n_year - 2023].get_month_arr()[n_month - 1].get_day_vec()[n_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
//std::cout << "***************" << endl;
auto nn_year = nextDay(n_year, n_month, n_day)[0];
auto nn_month = nextDay(n_year, n_month, n_day)[1];
auto nn_day = nextDay(n_year, n_month, n_day)[2];
if (year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_schedule_number() == 0)
{
cout<<f_green << "后天无日程" <<reset<< endl;
}
else if (year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_personal_schedule_number() != 0 && year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_team_schedule_number() == 0)
{
cout <<f_red<< "后天日程"<<reset << endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
/*cout << "无团队" << endl;*/
}
else if (year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_personal_schedule_number() == 0 && year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_team_schedule_number() != 0)
{
cout << f_red<<"后天日程" <<reset<< endl;
/*cout << "无个人" << endl;*/
cout << "团队:" << endl;
int j = 1;
for (auto ele : year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
else
{
cout <<f_red<< "后天日程" <<reset<< endl;
cout << "个人:" << endl;
int j = 1;
for (auto ele : year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_schedule_vec())
{
if (ele.gettype() == "person")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
cout << "团队:" << endl;
j = 1;
for (auto ele : year_vec[nn_year - 2023].get_month_arr()[nn_month - 1].get_day_vec()[nn_day - 1].get_schedule_vec())
{
if (ele.gettype() == "team")
{
std::cout << ele.getevent() << "~" <<
ele.gettime() << "~" << ele.getsite() << "~" << ele.getbeizhu() <<"..............................."<<j <<std::endl;
++j;
}
}
}
}
const std::vector<year> get_year_vec()//不能返回引用
{
std::vector<year>year_vec;
for(int i = 1;i <= 50;i++)
{
year_vec.emplace_back(year(2023 + i - 1));
}
return year_vec;
}
string user_func(user u)
{
year_vec=get_year_vec();
shared_riqi_vec.clear();
riqi_vec.clear();
system("cls");
//首次使用创建文件,后面已经创建了就别再截断文件
ofstream o_shared_file;
o_shared_file.open("G:/我的云端硬盘/Multi-function_calendar_data/shared_data",ofstream::app);
if (!o_shared_file.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(8);
}
o_shared_file.close();
std::ofstream ofile;
ofile.open("G:/我的云端硬盘/Multi-function_calendar_data/"+u.get_user_name(),ofstream::app);
if(!ofile.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(9);
}
ofile.close();
//读取文件数据
ifstream i_shared_file;
i_shared_file.open("G:/我的云端硬盘/Multi-function_calendar_data/shared_data");
if (!i_shared_file.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(-1);
}
unsigned int year_number = 0, month_number = 0, day_number = 0, personal_schedule_number = 0, team_schedule_number = 0;
string type, event, time, site,beizhu;
while (i_shared_file >> year_number >> month_number >> day_number >> team_schedule_number)
{
shared_riqi_vec.emplace_back(year_number, month_number, day_number);
i_shared_file.ignore();
for (unsigned int i = 1; i <= team_schedule_number; ++i)
{
getline(i_shared_file, type);
getline(i_shared_file, event);
getline(i_shared_file, time);
getline(i_shared_file, site);
getline(i_shared_file, beizhu);
year_vec[year_number - 2023].get_month_arr()[month_number - 1].get_day_vec()[day_number - 1].get_schedule_vec().emplace_back(schedule(type,event, time, site,beizhu));
}
}
i_shared_file.close();
std::ifstream ifile;
ifile.open("G:/我的云端硬盘/Multi-function_calendar_data/"+u.get_user_name());
if(!ifile.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(-2);
}
unsigned int last_message_number=0;
ifile >> last_message_number;
ifile.ignore();
message_number = dialogue_vec.size();
if(last_message_number == message_number)
{
wuxinxiaoxi = true;
}
else
{
wuxinxiaoxi = false;
}
while(ifile >> year_number >> month_number >> day_number >> personal_schedule_number)
{
riqi_vec.emplace_back(year_number,month_number,day_number);
ifile.ignore();
for(unsigned int i = 1;i <= personal_schedule_number;++i)
{
getline(ifile, type);
getline(ifile,event);
getline(ifile,time);
getline(ifile,site);
getline(ifile, beizhu);
year_vec[year_number - 2023].get_month_arr()[month_number - 1].get_day_vec()[day_number - 1].get_schedule_vec().emplace_back(schedule(type,event,time,site,beizhu));
}
}
ifile.close();
string s=main_interface(u);
o_shared_file.open("G:/我的云端硬盘/Multi-function_calendar_data/shared_data", ofstream::trunc);
if (!o_shared_file.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(-3);
}
sort(shared_riqi_vec.begin(), shared_riqi_vec.end());
auto iter2 = unique(shared_riqi_vec.begin(), shared_riqi_vec.end());
shared_riqi_vec.erase(iter2, shared_riqi_vec.end());
for (const auto& ele : shared_riqi_vec)
{
o_shared_file << ele.get_year_number() << " " << ele.get_month_number() << " " << ele.get_day_number() << " " << year_vec[ele.get_year_number() - 2023].get_month_arr()[ele.get_month_number() - 1].get_day_vec()[ele.get_day_number() - 1].get_team_schedule_number() << std::endl;
for (const auto& ele2 : year_vec[ele.get_year_number() - 2023].get_month_arr()[ele.get_month_number() - 1].get_day_vec()[ele.get_day_number() - 1].get_schedule_vec())
{
if (ele2.gettype() == "person")
{
continue;
}
o_shared_file << ele2.gettype() << endl;
o_shared_file << ele2.getevent() << endl;
o_shared_file << ele2.gettime() << endl;
o_shared_file << ele2.getsite() << endl;
o_shared_file << ele2.getbeizhu() << endl;
}
}
o_shared_file.close();
ofile.open("G:/我的云端硬盘/Multi-function_calendar_data/"+u.get_user_name(), ofstream::trunc);
if(!ofile.is_open())
{
std::cout << f_red << "操作失败:无法打开文件!" << reset << endl;
exit(-4);
}
ofile << dialogue_vec.size()<<endl;
sort(riqi_vec.begin(),riqi_vec.end());
auto iter = unique(riqi_vec.begin(),riqi_vec.end());
riqi_vec.erase(iter,riqi_vec.end());
for(const auto & ele : riqi_vec)
{
ofile << ele.get_year_number() << " " << ele.get_month_number() << " " << ele.get_day_number() << " " << year_vec[ele.get_year_number() - 2023].get_month_arr()[ele.get_month_number() - 1].get_day_vec()[ele.get_day_number() - 1].get_personal_schedule_number() << std::endl;
for(const auto & ele2 : year_vec[ele.get_year_number() - 2023].get_month_arr()[ele.get_month_number() - 1].get_day_vec()[ele.get_day_number() - 1].get_schedule_vec())
{
if (ele2.gettype() == "team")
{
continue;
}
ofile << ele2.gettype() << endl;
ofile << ele2.getevent() << endl;
ofile << ele2.gettime() << endl;
ofile << ele2.getsite() << endl;
ofile << ele2.getbeizhu() << endl;
}
}
ofile.close();
return s;
}
//
//string get_wps_path()
//{
// string s = "C:用户";
// for (const auto& ele : filesystem::directory_iterator(s))
// {
// if (ele.is_directory())
// {
// if (filesystem::exists(ele.path().string() + "/WPS云盘/共享文件夹"))
// {
// return ele.path().string() + "/WPS云盘/共享文件夹";
// }
// }
// }
// cout << f_red << "操作失败:wps云盘未保存在默认路径下!" << reset << endl;
// exit(4);
//}
void list_chengyuan(vector<user>&user_vec)
{
unsigned int guanliyuan_number = 0;
unsigned int qunchengyuan_number = 0;
for(auto& ele : user_vec)
{
if(ele.get_user_shenfen() == "管理员")
{
++guanliyuan_number;
}
}
for(auto& ele : user_vec)
{
if(ele.get_user_shenfen() == "群成员")
{
++qunchengyuan_number;
}
}
cout << "群主(1/" << user_vec.size()<<")" << endl;
auto iter=find_if(user_vec.begin(), user_vec.end(), [](const user& u)->bool{return u.get_user_shenfen() == "群主"; });
cout << iter->get_user_name()<<endl;
cout << "管理员(" <<guanliyuan_number<<"/"<<user_vec.size()<<")" << endl;
for(auto& ele : user_vec)
{
if(ele.get_user_shenfen() == "管理员")
{
cout << ele.get_user_name() << endl;
}
}
cout << "群成员(" << qunchengyuan_number << "/" << user_vec.size() << ")" << endl;
for(auto& ele : user_vec)
{
if(ele.get_user_shenfen() == "群成员")
{
cout << ele.get_user_name() << endl;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/yxyc-137/Team_collaboration_calendar.git
git@gitee.com:yxyc-137/Team_collaboration_calendar.git
yxyc-137
Team_collaboration_calendar
Team collaboration calendar
master

搜索帮助